Bug 1451198 part 1 - Move GetUnboxedValue and SetUnboxedValue to cpp file. r=bhackett
authorJan de Mooij <jdemooij@mozilla.com>
Sun, 22 Apr 2018 12:11:53 +0200
changeset 468528 5f017a1dc4a9f6b1631787aa7bb6b13352f8c3af
parent 468527 9b0196f1231627fea4471aa354c7bbd04e142086
child 468529 6c222e89103d4c70c58bf1955ab81cef8e8b62e1
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs1451198
milestone61.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 1451198 part 1 - Move GetUnboxedValue and SetUnboxedValue to cpp file. r=bhackett
js/src/vm/UnboxedObject-inl.h
js/src/vm/UnboxedObject.cpp
--- a/js/src/vm/UnboxedObject-inl.h
+++ b/js/src/vm/UnboxedObject-inl.h
@@ -10,113 +10,16 @@
 #include "vm/UnboxedObject.h"
 
 #include "gc/StoreBuffer-inl.h"
 #include "vm/ArrayObject-inl.h"
 #include "vm/NativeObject-inl.h"
 
 namespace js {
 
-static inline Value
-GetUnboxedValue(uint8_t* p, JSValueType type, bool maybeUninitialized)
-{
-    switch (type) {
-      case JSVAL_TYPE_BOOLEAN:
-        return BooleanValue(*p != 0);
-
-      case JSVAL_TYPE_INT32:
-        return Int32Value(*reinterpret_cast<int32_t*>(p));
-
-      case JSVAL_TYPE_DOUBLE: {
-        // During unboxed plain object creation, non-GC thing properties are
-        // left uninitialized. This is normally fine, since the properties will
-        // be filled in shortly, but if they are read before that happens we
-        // need to make sure that doubles are canonical.
-        double d = *reinterpret_cast<double*>(p);
-        if (maybeUninitialized)
-            return DoubleValue(JS::CanonicalizeNaN(d));
-        return DoubleValue(d);
-      }
-
-      case JSVAL_TYPE_STRING:
-        return StringValue(*reinterpret_cast<JSString**>(p));
-
-      case JSVAL_TYPE_OBJECT:
-        return ObjectOrNullValue(*reinterpret_cast<JSObject**>(p));
-
-      default:
-        MOZ_CRASH("Invalid type for unboxed value");
-    }
-}
-
-static inline bool
-SetUnboxedValue(JSContext* cx, JSObject* unboxedObject, jsid id,
-                uint8_t* p, JSValueType type, const Value& v, bool preBarrier)
-{
-    switch (type) {
-      case JSVAL_TYPE_BOOLEAN:
-        if (v.isBoolean()) {
-            *p = v.toBoolean();
-            return true;
-        }
-        return false;
-
-      case JSVAL_TYPE_INT32:
-        if (v.isInt32()) {
-            *reinterpret_cast<int32_t*>(p) = v.toInt32();
-            return true;
-        }
-        return false;
-
-      case JSVAL_TYPE_DOUBLE:
-        if (v.isNumber()) {
-            *reinterpret_cast<double*>(p) = v.toNumber();
-            return true;
-        }
-        return false;
-
-      case JSVAL_TYPE_STRING:
-        if (v.isString()) {
-            JSString** np = reinterpret_cast<JSString**>(p);
-            if (IsInsideNursery(v.toString()) && !IsInsideNursery(unboxedObject))
-                v.toString()->storeBuffer()->putWholeCell(unboxedObject);
-
-            if (preBarrier)
-                JSString::writeBarrierPre(*np);
-            *np = v.toString();
-            return true;
-        }
-        return false;
-
-      case JSVAL_TYPE_OBJECT:
-        if (v.isObjectOrNull()) {
-            JSObject** np = reinterpret_cast<JSObject**>(p);
-
-            // Update property types when writing object properties. Types for
-            // other properties were captured when the unboxed layout was
-            // created.
-            AddTypePropertyId(cx, unboxedObject, id, v);
-
-            // As above, trigger post barriers on the whole object.
-            JSObject* obj = v.toObjectOrNull();
-            if (IsInsideNursery(obj) && !IsInsideNursery(unboxedObject))
-                obj->storeBuffer()->putWholeCell(unboxedObject);
-
-            if (preBarrier)
-                JSObject::writeBarrierPre(*np);
-            *np = obj;
-            return true;
-        }
-        return false;
-
-      default:
-        MOZ_CRASH("Invalid type for unboxed value");
-    }
-}
-
 /////////////////////////////////////////////////////////////////////
 // UnboxedPlainObject
 /////////////////////////////////////////////////////////////////////
 
 inline const UnboxedLayout&
 UnboxedPlainObject::layout() const
 {
     return group()->unboxedLayout();
--- a/js/src/vm/UnboxedObject.cpp
+++ b/js/src/vm/UnboxedObject.cpp
@@ -301,16 +301,113 @@ UnboxedLayout::makeConstructorCode(JSCon
 
 void
 UnboxedLayout::detachFromCompartment()
 {
     if (isInList())
         remove();
 }
 
+static Value
+GetUnboxedValue(uint8_t* p, JSValueType type, bool maybeUninitialized)
+{
+    switch (type) {
+      case JSVAL_TYPE_BOOLEAN:
+        return BooleanValue(*p != 0);
+
+      case JSVAL_TYPE_INT32:
+        return Int32Value(*reinterpret_cast<int32_t*>(p));
+
+      case JSVAL_TYPE_DOUBLE: {
+        // During unboxed plain object creation, non-GC thing properties are
+        // left uninitialized. This is normally fine, since the properties will
+        // be filled in shortly, but if they are read before that happens we
+        // need to make sure that doubles are canonical.
+        double d = *reinterpret_cast<double*>(p);
+        if (maybeUninitialized)
+            return DoubleValue(JS::CanonicalizeNaN(d));
+        return DoubleValue(d);
+      }
+
+      case JSVAL_TYPE_STRING:
+        return StringValue(*reinterpret_cast<JSString**>(p));
+
+      case JSVAL_TYPE_OBJECT:
+        return ObjectOrNullValue(*reinterpret_cast<JSObject**>(p));
+
+      default:
+        MOZ_CRASH("Invalid type for unboxed value");
+    }
+}
+
+static bool
+SetUnboxedValue(JSContext* cx, JSObject* unboxedObject, jsid id,
+                uint8_t* p, JSValueType type, const Value& v, bool preBarrier)
+{
+    switch (type) {
+      case JSVAL_TYPE_BOOLEAN:
+        if (v.isBoolean()) {
+            *p = v.toBoolean();
+            return true;
+        }
+        return false;
+
+      case JSVAL_TYPE_INT32:
+        if (v.isInt32()) {
+            *reinterpret_cast<int32_t*>(p) = v.toInt32();
+            return true;
+        }
+        return false;
+
+      case JSVAL_TYPE_DOUBLE:
+        if (v.isNumber()) {
+            *reinterpret_cast<double*>(p) = v.toNumber();
+            return true;
+        }
+        return false;
+
+      case JSVAL_TYPE_STRING:
+        if (v.isString()) {
+            JSString** np = reinterpret_cast<JSString**>(p);
+            if (IsInsideNursery(v.toString()) && !IsInsideNursery(unboxedObject))
+                v.toString()->storeBuffer()->putWholeCell(unboxedObject);
+
+            if (preBarrier)
+                JSString::writeBarrierPre(*np);
+            *np = v.toString();
+            return true;
+        }
+        return false;
+
+      case JSVAL_TYPE_OBJECT:
+        if (v.isObjectOrNull()) {
+            JSObject** np = reinterpret_cast<JSObject**>(p);
+
+            // Update property types when writing object properties. Types for
+            // other properties were captured when the unboxed layout was
+            // created.
+            AddTypePropertyId(cx, unboxedObject, id, v);
+
+            // As above, trigger post barriers on the whole object.
+            JSObject* obj = v.toObjectOrNull();
+            if (IsInsideNursery(obj) && !IsInsideNursery(unboxedObject))
+                obj->storeBuffer()->putWholeCell(unboxedObject);
+
+            if (preBarrier)
+                JSObject::writeBarrierPre(*np);
+            *np = obj;
+            return true;
+        }
+        return false;
+
+      default:
+        MOZ_CRASH("Invalid type for unboxed value");
+    }
+}
+
 /////////////////////////////////////////////////////////////////////
 // UnboxedPlainObject
 /////////////////////////////////////////////////////////////////////
 
 bool
 UnboxedPlainObject::setValue(JSContext* cx, const UnboxedLayout::Property& property,
                              const Value& v)
 {