Backed out 10 changesets (bug 1439026) for spidermonkey-sm-nonunified-linux64 bustages. a=backout on a CLOSED TREE
authorCiure Andrei <aciure@mozilla.com>
Fri, 02 Mar 2018 15:57:52 +0200
changeset 461339 77728b046b9572d38d0c576ca93a07d767c75018
parent 461338 387dadb053283c2d8a13435dd4e3f3c88811469a
child 461340 d3b20e603c5fe0c96c0d4a0b58a5b189dc7467b8
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1439026
milestone60.0a1
backs out27658d23e3cf92111667948303c47df9e76d98b9
e7894f7f0e5b5941de180aedc611c91e5f36b420
f15edbbe39ab9371750c9f1b0068892a2266be2f
e745fe9ab05aa6a877230fc451be0bac38a9a8f6
ac2b65f3fb198387bce7e562b173892abc3097a5
7c3f8382395d88b33c067941c5ba528bd3a71394
17c547757a7a5da24da4f41f19f370d8f4f9b41e
07d69d9954c1165f66a275f047517f2e57e640df
cfd781da349e59c8d6b9fea7efed04a0b2124a61
72a84df56d3901e17b78b5cc7698cee8883f6614
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
Backed out 10 changesets (bug 1439026) for spidermonkey-sm-nonunified-linux64 bustages. a=backout on a CLOSED TREE Backed out changeset 27658d23e3cf (bug 1439026) Backed out changeset e7894f7f0e5b (bug 1439026) Backed out changeset f15edbbe39ab (bug 1439026) Backed out changeset e745fe9ab05a (bug 1439026) Backed out changeset ac2b65f3fb19 (bug 1439026) Backed out changeset 7c3f8382395d (bug 1439026) Backed out changeset 17c547757a7a (bug 1439026) Backed out changeset 07d69d9954c1 (bug 1439026) Backed out changeset cfd781da349e (bug 1439026) Backed out changeset 72a84df56d39 (bug 1439026)
js/src/builtin/Array-inl.h
js/src/builtin/Array.cpp
js/src/builtin/Array.h
js/src/builtin/Atomics.cpp
js/src/builtin/Atomics.h
js/src/builtin/AtomicsObject.cpp
js/src/builtin/AtomicsObject.h
js/src/builtin/Boolean-inl.h
js/src/builtin/Boolean.cpp
js/src/builtin/Boolean.h
js/src/builtin/DataView.cpp
js/src/builtin/DataView.h
js/src/builtin/DataViewObject.cpp
js/src/builtin/DataViewObject.h
js/src/builtin/Date.cpp
js/src/builtin/Date.h
js/src/builtin/JSON.cpp
js/src/builtin/Map.cpp
js/src/builtin/Map.h
js/src/builtin/MapObject.cpp
js/src/builtin/MapObject.h
js/src/builtin/Math.cpp
js/src/builtin/Math.h
js/src/builtin/Number.cpp
js/src/builtin/Number.h
js/src/builtin/Object.cpp
js/src/builtin/Reflect.cpp
js/src/builtin/ReflectParse.cpp
js/src/builtin/RegExp.cpp
js/src/builtin/SIMD.cpp
js/src/builtin/String.cpp
js/src/builtin/String.h
js/src/builtin/Symbol.cpp
js/src/builtin/Symbol.h
js/src/builtin/SymbolObject.cpp
js/src/builtin/SymbolObject.h
js/src/builtin/TestingFunctions.cpp
js/src/builtin/TypedObject.cpp
js/src/builtin/WeakMap-inl.h
js/src/builtin/WeakMap.cpp
js/src/builtin/WeakMap.h
js/src/builtin/WeakMapObject-inl.h
js/src/builtin/WeakMapObject.cpp
js/src/builtin/WeakMapObject.h
js/src/builtin/WeakSet.cpp
js/src/builtin/WeakSet.h
js/src/builtin/WeakSetObject.cpp
js/src/builtin/WeakSetObject.h
js/src/builtin/intl/Collator.cpp
js/src/builtin/intl/CommonFunctions.h
js/src/builtin/intl/Intl.cpp
js/src/builtin/intl/Intl.h
js/src/builtin/intl/Intl.js
js/src/builtin/intl/IntlObject.cpp
js/src/builtin/intl/IntlObject.h
js/src/builtin/intl/IntlObject.js
js/src/builtin/intl/PluralRules.cpp
js/src/builtin/intl/SharedIntlData.cpp
js/src/builtin/intl/SharedIntlData.h
js/src/ctypes/CTypes.cpp
js/src/ctypes/CTypes.h
js/src/frontend/BytecodeCompiler.h
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/FoldConstants.cpp
js/src/frontend/NameFunctions.cpp
js/src/frontend/Parser.cpp
js/src/frontend/TokenStream.cpp
js/src/frontend/TokenStream.h
js/src/gc/Allocator.cpp
js/src/gc/AtomMarking.h
js/src/gc/Barrier.cpp
js/src/gc/GC.cpp
js/src/gc/Marking.cpp
js/src/gc/RootMarking.cpp
js/src/gc/Statistics.cpp
js/src/gc/Tracer.cpp
js/src/gdb/tests/test-JSString.cpp
js/src/irregexp/RegExpParser.cpp
js/src/jit/BaselineIC.cpp
js/src/jit/CacheIRCompiler.cpp
js/src/jit/CodeGenerator.cpp
js/src/jit/EffectiveAddressAnalysis.cpp
js/src/jit/IonAnalysis.cpp
js/src/jit/IonBuilder.cpp
js/src/jit/IonTypes.h
js/src/jit/MCallOptimize.cpp
js/src/jit/MIR.cpp
js/src/jit/OptimizationTracking.cpp
js/src/jit/ProcessExecutableMemory.cpp
js/src/jit/RangeAnalysis.cpp
js/src/jit/Recover.cpp
js/src/jit/Recover.h
js/src/jit/SharedIC.cpp
js/src/jit/arm/CodeGenerator-arm.cpp
js/src/jit/arm64/CodeGenerator-arm64.cpp
js/src/jit/mips-shared/AtomicOperations-mips-shared.h
js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp
js/src/jit/mips32/SharedIC-mips32.cpp
js/src/jit/mips64/SharedIC-mips64.cpp
js/src/jit/shared/Lowering-shared.cpp
js/src/jit/x86-shared/CodeGenerator-x86-shared.cpp
js/src/jit/x86/CodeGenerator-x86.cpp
js/src/jsapi-tests/testErrorInterceptor.cpp
js/src/jsapi-tests/testIndexToString.cpp
js/src/jsapi-tests/testIntern.cpp
js/src/jsapi-tests/testParseJSON.cpp
js/src/jsapi-tests/testSavedStacks.cpp
js/src/jsapi-tests/testSharedImmutableStringsCache.cpp
js/src/jsapi-tests/testStringBuffer.cpp
js/src/jsapi-tests/testUTF8.cpp
js/src/jsapi-tests/testUbiNode.cpp
js/src/jsapi-tests/testXDR.cpp
js/src/jsapi.cpp
js/src/jsarray.cpp
js/src/jsarray.h
js/src/jsarrayinlines.h
js/src/jsbool.cpp
js/src/jsbool.h
js/src/jsboolinlines.h
js/src/jsdate.cpp
js/src/jsdate.h
js/src/jsexn.cpp
js/src/jsfriendapi.h
js/src/jslibmath.h
js/src/jsmath.cpp
js/src/jsmath.h
js/src/jsnum.cpp
js/src/jsnum.h
js/src/jsstr.cpp
js/src/jsstr.h
js/src/moz.build
js/src/proxy/SecurityWrapper.cpp
js/src/shell/OSObject.cpp
js/src/shell/js.cpp
js/src/shell/jsshell.cpp
js/src/util/PortableMath.h
js/src/util/StringBuffer.cpp
js/src/util/StringBuffer.h
js/src/util/Text.cpp
js/src/util/Text.h
js/src/util/Unicode.cpp
js/src/util/Unicode.h
js/src/util/UnicodeData.txt
js/src/util/UnicodeNonBMP.h
js/src/util/make_unicode.py
js/src/vm/ArrayBufferObject.cpp
js/src/vm/ArrayObject-inl.h
js/src/vm/AsyncIteration.cpp
js/src/vm/BooleanObject.h
js/src/vm/BytecodeUtil.cpp
js/src/vm/Caches.h
js/src/vm/CodeCoverage.cpp
js/src/vm/Debugger.cpp
js/src/vm/DebuggerMemory.cpp
js/src/vm/ErrorObject.cpp
js/src/vm/GeckoProfiler.cpp
js/src/vm/GlobalObject.cpp
js/src/vm/GlobalObject.h
js/src/vm/Initialization.cpp
js/src/vm/Interpreter-inl.h
js/src/vm/Interpreter.cpp
js/src/vm/Iteration.cpp
js/src/vm/JSAtom-inl.h
js/src/vm/JSAtom.cpp
js/src/vm/JSContext-inl.h
js/src/vm/JSContext.cpp
js/src/vm/JSFunction.cpp
js/src/vm/JSONParser.cpp
js/src/vm/JSONParser.h
js/src/vm/JSObject-inl.h
js/src/vm/JSObject.cpp
js/src/vm/JSObject.h
js/src/vm/JSScript.cpp
js/src/vm/MemoryMetrics.cpp
js/src/vm/NativeObject.h
js/src/vm/NumberObject.h
js/src/vm/ObjectGroup.cpp
js/src/vm/RegExpObject.cpp
js/src/vm/Runtime.cpp
js/src/vm/Runtime.h
js/src/vm/SavedStacks.cpp
js/src/vm/SavedStacks.h
js/src/vm/Scope.cpp
js/src/vm/SelfHosting.cpp
js/src/vm/Shape.cpp
js/src/vm/Shape.h
js/src/vm/SharedImmutableStringsCache.cpp
js/src/vm/SharedImmutableStringsCache.h
js/src/vm/String-inl.h
js/src/vm/String.cpp
js/src/vm/String.h
js/src/vm/StringBuffer.cpp
js/src/vm/StringBuffer.h
js/src/vm/StringObject.h
js/src/vm/StringType-inl.h
js/src/vm/StringType.cpp
js/src/vm/StringType.h
js/src/vm/StructuredClone.cpp
js/src/vm/Symbol.cpp
js/src/vm/Symbol.h
js/src/vm/SymbolType.cpp
js/src/vm/SymbolType.h
js/src/vm/TraceLoggingGraph.cpp
js/src/vm/TraceLoggingTypes.cpp
js/src/vm/TraceLoggingTypes.h
js/src/vm/TypeInference-inl.h
js/src/vm/TypeInference.cpp
js/src/vm/TypedArrayObject-inl.h
js/src/vm/TypedArrayObject.cpp
js/src/vm/UbiNode.cpp
js/src/vm/UbiNodeCensus.cpp
js/src/vm/UbiNodeShortestPaths.cpp
js/src/vm/Unicode.cpp
js/src/vm/Unicode.h
js/src/vm/UnicodeData.txt
js/src/vm/UnicodeNonBMP.h
js/src/vm/make_unicode.py
js/src/wasm/AsmJS.cpp
js/src/wasm/WasmBinaryToText.cpp
js/src/wasm/WasmBuiltins.cpp
js/src/wasm/WasmCompile.cpp
js/src/wasm/WasmDebug.cpp
js/src/wasm/WasmGenerator.cpp
js/src/wasm/WasmJS.cpp
js/src/wasm/WasmTextToBinary.cpp
js/src/wasm/WasmTextUtils.cpp
js/src/wasm/WasmTextUtils.h
rename from js/src/builtin/Atomics.cpp
rename to js/src/builtin/AtomicsObject.cpp
--- a/js/src/builtin/Atomics.cpp
+++ b/js/src/builtin/AtomicsObject.cpp
@@ -40,29 +40,29 @@
  * gcc/Clang intrinsics with simple code below using the VC++
  * intrinsics, like the VC++2012 solution this is a stopgap since
  * we're about to start using VC++2013 anyway.
  *
  * If none of those options are available then the build must disable
  * shared memory, or compilation will fail with a predictable error.
  */
 
-#include "builtin/Atomics.h"
+#include "builtin/AtomicsObject.h"
 
 #include "mozilla/Atomics.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/ScopeExit.h"
 #include "mozilla/Unused.h"
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
+#include "jsnum.h"
 
-#include "builtin/Number.h"
 #include "jit/AtomicOperations.h"
 #include "jit/InlinableNatives.h"
 #include "js/Class.h"
 #include "vm/GlobalObject.h"
 #include "vm/Time.h"
 #include "vm/TypedArrayObject.h"
 #include "wasm/WasmInstance.h"
 
rename from js/src/builtin/Atomics.h
rename to js/src/builtin/AtomicsObject.h
--- a/js/src/builtin/Atomics.h
+++ b/js/src/builtin/AtomicsObject.h
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef builtin_Atomics_h
-#define builtin_Atomics_h
+#ifndef builtin_AtomicsObject_h
+#define builtin_AtomicsObject_h
 
 #include "mozilla/Maybe.h"
 #include "mozilla/TimeStamp.h"
 
 #include "threading/ConditionVariable.h"
 #include "vm/JSObject.h"
 #include "vm/MutexIDs.h"
 #include "vm/NativeObject.h"
@@ -157,9 +157,9 @@ atomics_wait_impl(JSContext* cx, SharedA
 // all.  The return value is nonnegative and is the number of waiters woken.  If
 // the number of waiters woken exceeds INT64_MAX then this never returns.  If
 // `count` is nonnegative then the return value is never greater than `count`.
 MOZ_MUST_USE int64_t
 atomics_wake_impl(SharedArrayRawBuffer* sarb, uint32_t byteOffset, int64_t count);
 
 }  /* namespace js */
 
-#endif /* builtin_Atomics_h */
+#endif /* builtin_AtomicsObject_h */
rename from js/src/builtin/DataView.cpp
rename to js/src/builtin/DataViewObject.cpp
--- a/js/src/builtin/DataView.cpp
+++ b/js/src/builtin/DataViewObject.cpp
@@ -1,26 +1,26 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "builtin/DataView.h"
+#include "builtin/DataViewObject.h"
 
 #include "mozilla/Alignment.h"
 #include "mozilla/Casting.h"
 #include "mozilla/EndianUtils.h"
 
 #include <string.h>
 
 #include "jsapi.h"
+#include "jsarray.h"
+#include "jsnum.h"
 
-#include "builtin/Array.h"
-#include "builtin/Number.h"
 #include "jit/AtomicOperations.h"
 #include "js/Conversions.h"
 #include "js/Wrapper.h"
 #include "util/Windows.h"
 #include "vm/ArrayBufferObject.h"
 #include "vm/GlobalObject.h"
 #include "vm/Interpreter.h"
 #include "vm/JSContext.h"
rename from js/src/builtin/DataView.h
rename to js/src/builtin/DataViewObject.h
--- a/js/src/builtin/JSON.cpp
+++ b/js/src/builtin/JSON.cpp
@@ -5,31 +5,32 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "builtin/JSON.h"
 
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/Range.h"
 #include "mozilla/ScopeExit.h"
 
+#include "jsarray.h"
+#include "jsnum.h"
+#include "jsstr.h"
 #include "jstypes.h"
 #include "jsutil.h"
 
-#include "builtin/Array.h"
-#include "builtin/Number.h"
-#include "builtin/String.h"
-#include "util/StringBuffer.h"
 #include "vm/Interpreter.h"
 #include "vm/JSAtom.h"
 #include "vm/JSContext.h"
 #include "vm/JSObject.h"
 #include "vm/JSONParser.h"
+#include "vm/StringBuffer.h"
 
-#include "builtin/Array-inl.h"
-#include "builtin/Boolean-inl.h"
+#include "jsarrayinlines.h"
+#include "jsboolinlines.h"
+
 #include "vm/JSAtom-inl.h"
 #include "vm/NativeObject-inl.h"
 
 using namespace js;
 using namespace js::gc;
 
 using mozilla::IsFinite;
 using mozilla::Maybe;
rename from js/src/builtin/Map.cpp
rename to js/src/builtin/MapObject.cpp
--- a/js/src/builtin/Map.cpp
+++ b/js/src/builtin/MapObject.cpp
@@ -1,26 +1,26 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "builtin/Map.h"
+#include "builtin/MapObject.h"
 
 #include "ds/OrderedHashTable.h"
 #include "gc/FreeOp.h"
 #include "js/Utility.h"
 #include "vm/GlobalObject.h"
 #include "vm/Interpreter.h"
 #include "vm/Iteration.h"
 #include "vm/JSContext.h"
 #include "vm/JSObject.h"
 #include "vm/SelfHosting.h"
-#include "vm/SymbolType.h"
+#include "vm/Symbol.h"
 
 #include "gc/Marking-inl.h"
 #include "vm/Interpreter-inl.h"
 #include "vm/NativeObject-inl.h"
 
 using namespace js;
 
 using mozilla::IsNaN;
rename from js/src/builtin/Map.h
rename to js/src/builtin/MapObject.h
--- a/js/src/builtin/Map.h
+++ b/js/src/builtin/MapObject.h
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef builtin_Map_h
-#define builtin_Map_h
+#ifndef builtin_MapObject_h
+#define builtin_MapObject_h
 
 #include "builtin/SelfHostingDefines.h"
 #include "vm/GlobalObject.h"
 #include "vm/JSObject.h"
 #include "vm/NativeObject.h"
 #include "vm/PIC.h"
 #include "vm/Runtime.h"
 
@@ -342,9 +342,9 @@ IsOptimizableInitForSet(JSContext* cx, H
     if (!stubChain)
         return false;
 
     return stubChain->tryOptimizeArray(cx, array.as<ArrayObject>(), optimized);
 }
 
 } /* namespace js */
 
-#endif /* builtin_Map_h */
+#endif /* builtin_MapObject_h */
--- a/js/src/builtin/Object.cpp
+++ b/js/src/builtin/Object.cpp
@@ -3,26 +3,27 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "builtin/Object.h"
 
 #include "mozilla/MaybeOneOf.h"
 
+#include "jsstr.h"
+
 #include "builtin/Eval.h"
 #include "builtin/SelfHostingDefines.h"
-#include "builtin/String.h"
 #include "frontend/BytecodeCompiler.h"
 #include "jit/InlinableNatives.h"
 #include "js/UniquePtr.h"
-#include "util/StringBuffer.h"
 #include "vm/AsyncFunction.h"
 #include "vm/JSContext.h"
 #include "vm/RegExpObject.h"
+#include "vm/StringBuffer.h"
 
 #include "vm/JSObject-inl.h"
 #include "vm/NativeObject-inl.h"
 #include "vm/Shape-inl.h"
 #include "vm/UnboxedObject-inl.h"
 
 #ifdef FUZZING
 #include "builtin/TestingFunctions.h"
--- a/js/src/builtin/Reflect.cpp
+++ b/js/src/builtin/Reflect.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "builtin/Reflect.h"
 
-#include "builtin/Array.h"
+#include "jsarray.h"
 
 #include "jit/InlinableNatives.h"
 #include "vm/ArgumentsObject.h"
 #include "vm/JSContext.h"
 #include "vm/Stack.h"
 
 #include "vm/Interpreter-inl.h"
 
--- a/js/src/builtin/ReflectParse.cpp
+++ b/js/src/builtin/ReflectParse.cpp
@@ -6,19 +6,19 @@
 
 /* JS reflection package. */
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Move.h"
 
 #include <stdlib.h>
 
+#include "jsarray.h"
 #include "jspubtd.h"
 
-#include "builtin/Array.h"
 #include "builtin/Reflect.h"
 #include "frontend/Parser.h"
 #include "frontend/TokenStream.h"
 #include "js/CharacterEncoding.h"
 #include "vm/JSAtom.h"
 #include "vm/JSObject.h"
 #include "vm/RegExpObject.h"
 
--- a/js/src/builtin/RegExp.cpp
+++ b/js/src/builtin/RegExp.cpp
@@ -7,21 +7,21 @@
 #include "builtin/RegExp.h"
 
 #include "mozilla/CheckedInt.h"
 #include "mozilla/TypeTraits.h"
 
 #include "frontend/TokenStream.h"
 #include "irregexp/RegExpParser.h"
 #include "jit/InlinableNatives.h"
-#include "util/StringBuffer.h"
-#include "util/Unicode.h"
 #include "vm/JSContext.h"
 #include "vm/RegExpStatics.h"
 #include "vm/SelfHosting.h"
+#include "vm/StringBuffer.h"
+#include "vm/Unicode.h"
 
 #include "vm/JSObject-inl.h"
 #include "vm/NativeObject-inl.h"
 #include "vm/UnboxedObject-inl.h"
 
 using namespace js;
 using namespace js::unicode;
 
--- a/js/src/builtin/SIMD.cpp
+++ b/js/src/builtin/SIMD.cpp
@@ -15,18 +15,18 @@
 
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/IntegerTypeTraits.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/TypeTraits.h"
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
+#include "jsnum.h"
 
-#include "builtin/Number.h"
 #include "builtin/TypedObject.h"
 #include "jit/AtomicOperations.h"
 #include "jit/InlinableNatives.h"
 #include "js/Value.h"
 
 #include "vm/JSObject-inl.h"
 
 using namespace js;
rename from js/src/builtin/Symbol.cpp
rename to js/src/builtin/SymbolObject.cpp
--- a/js/src/builtin/Symbol.cpp
+++ b/js/src/builtin/SymbolObject.cpp
@@ -1,18 +1,18 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "builtin/Symbol.h"
+#include "builtin/SymbolObject.h"
 
-#include "util/StringBuffer.h"
-#include "vm/SymbolType.h"
+#include "vm/StringBuffer.h"
+#include "vm/Symbol.h"
 
 #include "vm/JSObject-inl.h"
 #include "vm/NativeObject-inl.h"
 
 using JS::Symbol;
 using namespace js;
 
 const Class SymbolObject::class_ = {
rename from js/src/builtin/Symbol.h
rename to js/src/builtin/SymbolObject.h
--- a/js/src/builtin/Symbol.h
+++ b/js/src/builtin/SymbolObject.h
@@ -1,19 +1,19 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef builtin_Symbol_h
-#define builtin_Symbol_h
+#ifndef builtin_SymbolObject_h
+#define builtin_SymbolObject_h
 
 #include "vm/NativeObject.h"
-#include "vm/SymbolType.h"
+#include "vm/Symbol.h"
 
 namespace js {
 
 class SymbolObject : public NativeObject
 {
     /* Stores this Symbol object's [[PrimitiveValue]]. */
     static const unsigned PRIMITIVE_VALUE_SLOT = 0;
 
@@ -60,9 +60,9 @@ class SymbolObject : public NativeObject
 extern JSObject*
 InitSymbolClass(JSContext* cx, HandleObject obj);
 
 extern JSObject*
 InitBareSymbolCtor(JSContext* cx, HandleObject obj);
 
 } /* namespace js */
 
-#endif /* builtin_Symbol_h */
+#endif /* builtin_SymbolObject_h */
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -33,29 +33,28 @@
 #include "js/HashTable.h"
 #include "js/StructuredClone.h"
 #include "js/UbiNode.h"
 #include "js/UbiNodeBreadthFirst.h"
 #include "js/UbiNodeShortestPaths.h"
 #include "js/UniquePtr.h"
 #include "js/Vector.h"
 #include "js/Wrapper.h"
-#include "util/StringBuffer.h"
-#include "util/Text.h"
 #include "vm/AsyncFunction.h"
 #include "vm/AsyncIteration.h"
 #include "vm/Debugger.h"
 #include "vm/GlobalObject.h"
 #include "vm/Interpreter.h"
 #include "vm/Iteration.h"
 #include "vm/JSContext.h"
 #include "vm/JSObject.h"
 #include "vm/ProxyObject.h"
 #include "vm/SavedStacks.h"
 #include "vm/Stack.h"
+#include "vm/StringBuffer.h"
 #include "vm/TraceLogging.h"
 #include "wasm/AsmJS.h"
 #include "wasm/WasmBinaryToText.h"
 #include "wasm/WasmJS.h"
 #include "wasm/WasmModule.h"
 #include "wasm/WasmSignalHandlers.h"
 #include "wasm/WasmTextToBinary.h"
 #include "wasm/WasmTypes.h"
--- a/js/src/builtin/TypedObject.cpp
+++ b/js/src/builtin/TypedObject.cpp
@@ -9,21 +9,21 @@
 #include "mozilla/Casting.h"
 #include "mozilla/CheckedInt.h"
 
 #include "jsutil.h"
 
 #include "builtin/SIMD.h"
 #include "gc/Marking.h"
 #include "js/Vector.h"
-#include "util/StringBuffer.h"
 #include "vm/GlobalObject.h"
 #include "vm/JSCompartment.h"
 #include "vm/JSFunction.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
+#include "vm/StringBuffer.h"
 #include "vm/TypedArrayObject.h"
 
 #include "gc/Nursery-inl.h"
 #include "gc/StoreBuffer-inl.h"
 #include "vm/JSAtom-inl.h"
 #include "vm/JSObject-inl.h"
 #include "vm/NativeObject-inl.h"
 #include "vm/Shape-inl.h"
rename from js/src/builtin/WeakMap-inl.h
rename to js/src/builtin/WeakMapObject-inl.h
--- a/js/src/builtin/WeakMap-inl.h
+++ b/js/src/builtin/WeakMapObject-inl.h
@@ -1,18 +1,18 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef builtin_WeakMap_inl_h
-#define builtin_WeakMap_inl_h
+#ifndef builtin_WeakMapObject_inl_h
+#define builtin_WeakMapObject_inl_h
 
-#include "builtin/WeakMap.h"
+#include "builtin/WeakMapObject.h"
 
 #include "vm/ProxyObject.h"
 
 namespace js {
 
 static bool
 TryPreserveReflector(JSContext* cx, HandleObject obj)
 {
@@ -63,9 +63,9 @@ WeakCollectionPutEntryInternal(JSContext
         JS_ReportOutOfMemory(cx);
         return false;
     }
     return true;
 }
 
 } // namespace js
 
-#endif /* builtin_WeakMap_inl_h */
+#endif /* builtin_WeakMapObject_inl_h */
rename from js/src/builtin/WeakMap.cpp
rename to js/src/builtin/WeakMapObject.cpp
--- a/js/src/builtin/WeakMap.cpp
+++ b/js/src/builtin/WeakMapObject.cpp
@@ -1,19 +1,19 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "builtin/WeakMap-inl.h"
+#include "builtin/WeakMapObject-inl.h"
 
 #include "jsapi.h"
 
-#include "builtin/WeakSet.h"
+#include "builtin/WeakSetObject.h"
 #include "gc/FreeOp.h"
 #include "vm/JSContext.h"
 #include "vm/SelfHosting.h"
 
 #include "vm/Interpreter-inl.h"
 
 using namespace js;
 using namespace js::gc;
rename from js/src/builtin/WeakMap.h
rename to js/src/builtin/WeakMapObject.h
--- a/js/src/builtin/WeakMap.h
+++ b/js/src/builtin/WeakMapObject.h
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef builtin_WeakMap_h
-#define builtin_WeakMap_h
+#ifndef builtin_WeakMapObject_h
+#define builtin_WeakMapObject_h
 
 #include "gc/WeakMap.h"
 #include "vm/JSObject.h"
 
 namespace js {
 
 // Abstract base class for WeakMapObject and WeakSetObject.
 class WeakCollectionObject : public NativeObject
@@ -32,9 +32,9 @@ class WeakMapObject : public WeakCollect
     static const Class class_;
 };
 
 extern JSObject*
 InitWeakMapClass(JSContext* cx, HandleObject obj);
 
 } // namespace js
 
-#endif /* builtin_WeakMap_h */
+#endif /* builtin_WeakMapObject_h */
rename from js/src/builtin/WeakSet.cpp
rename to js/src/builtin/WeakSetObject.cpp
--- a/js/src/builtin/WeakSet.cpp
+++ b/js/src/builtin/WeakSetObject.cpp
@@ -1,25 +1,25 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "builtin/WeakSet.h"
+#include "builtin/WeakSetObject.h"
 
 #include "jsapi.h"
 
-#include "builtin/Map.h"
+#include "builtin/MapObject.h"
 #include "vm/GlobalObject.h"
 #include "vm/Iteration.h"
 #include "vm/JSContext.h"
 #include "vm/SelfHosting.h"
 
-#include "builtin/WeakMap-inl.h"
+#include "builtin/WeakMapObject-inl.h"
 #include "vm/Interpreter-inl.h"
 #include "vm/JSObject-inl.h"
 #include "vm/NativeObject-inl.h"
 
 using namespace js;
 
 MOZ_ALWAYS_INLINE bool
 IsWeakSet(HandleValue v)
rename from js/src/builtin/WeakSet.h
rename to js/src/builtin/WeakSetObject.h
--- a/js/src/builtin/WeakSet.h
+++ b/js/src/builtin/WeakSetObject.h
@@ -1,18 +1,18 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef builtin_WeakSet_h
-#define builtin_WeakSet_h
+#ifndef builtin_WeakSetObject_h
+#define builtin_WeakSetObject_h
 
-#include "builtin/WeakMap.h"
+#include "builtin/WeakMapObject.h"
 
 namespace js {
 
 class WeakSetObject : public WeakCollectionObject
 {
   public:
     static JSObject* initClass(JSContext* cx, HandleObject obj);
     static const Class class_;
@@ -34,9 +34,9 @@ InitWeakSetClass(JSContext* cx, HandleOb
 
 template<>
 inline bool
 JSObject::is<js::WeakCollectionObject>() const
 {
     return is<js::WeakMapObject>() || is<js::WeakSetObject>();
 }
 
-#endif /* builtin_WeakSet_h */
+#endif /* builtin_WeakSetObject_h */
--- a/js/src/builtin/intl/Collator.cpp
+++ b/js/src/builtin/intl/Collator.cpp
@@ -16,17 +16,17 @@
 #include "builtin/intl/ICUStubs.h"
 #include "builtin/intl/ScopedICUObject.h"
 #include "builtin/intl/SharedIntlData.h"
 #include "gc/FreeOp.h"
 #include "js/TypeDecls.h"
 #include "vm/GlobalObject.h"
 #include "vm/JSContext.h"
 #include "vm/Runtime.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 
 #include "vm/JSObject-inl.h"
 
 using namespace js;
 
 using js::intl::GetAvailableLocales;
 using js::intl::IcuLocale;
 using js::intl::ReportInternalError;
--- a/js/src/builtin/intl/CommonFunctions.h
+++ b/js/src/builtin/intl/CommonFunctions.h
@@ -12,17 +12,17 @@
 
 #include <stddef.h>
 #include <stdint.h>
 #include <string.h>
 
 #include "builtin/intl/ICUStubs.h"
 #include "js/RootingAPI.h"
 #include "js/Vector.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 
 namespace js {
 
 namespace intl {
 
 /**
  * Initialize a new Intl.* object using the named self-hosted function.
  */
rename from js/src/builtin/intl/Intl.cpp
rename to js/src/builtin/intl/IntlObject.cpp
--- a/js/src/builtin/intl/Intl.cpp
+++ b/js/src/builtin/intl/IntlObject.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* Implementation of the Intl object and its non-constructor properties. */
 
-#include "builtin/intl/Intl.h"
+#include "builtin/intl/IntlObject.h"
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Likely.h"
 #include "mozilla/Range.h"
 
 #include "jsapi.h"
 
 #include "builtin/intl/Collator.h"
@@ -20,17 +20,17 @@
 #include "builtin/intl/ICUStubs.h"
 #include "builtin/intl/NumberFormat.h"
 #include "builtin/intl/PluralRules.h"
 #include "builtin/intl/ScopedICUObject.h"
 #include "js/Class.h"
 #include "vm/GlobalObject.h"
 #include "vm/JSContext.h"
 #include "vm/JSObject.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 
 #include "vm/JSObject-inl.h"
 
 using namespace js;
 
 using mozilla::Range;
 using mozilla::RangedPtr;
 
rename from js/src/builtin/intl/Intl.h
rename to js/src/builtin/intl/IntlObject.h
--- a/js/src/builtin/intl/Intl.h
+++ b/js/src/builtin/intl/IntlObject.h
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef builtin_intl_Intl_h
-#define builtin_intl_Intl_h
+#ifndef builtin_intl_IntlObject_h
+#define builtin_intl_IntlObject_h
 
 #include "mozilla/Attributes.h"
 
 #include "js/RootingAPI.h"
 #include "js/TypeDecls.h"
 
 namespace js {
 
@@ -100,9 +100,9 @@ intl_GetLocaleInfo(JSContext* cx, unsign
  *   'AM'
  * ]
  */
 extern MOZ_MUST_USE bool
 intl_ComputeDisplayNames(JSContext* cx, unsigned argc, JS::Value* vp);
 
 } // namespace js
 
-#endif /* builtin_intl_Intl_h */
+#endif /* builtin_intl_IntlObject_h */
rename from js/src/builtin/intl/Intl.js
rename to js/src/builtin/intl/IntlObject.js
--- a/js/src/builtin/intl/PluralRules.cpp
+++ b/js/src/builtin/intl/PluralRules.cpp
@@ -12,17 +12,17 @@
 #include "mozilla/Casting.h"
 
 #include "builtin/intl/CommonFunctions.h"
 #include "builtin/intl/ICUStubs.h"
 #include "builtin/intl/ScopedICUObject.h"
 #include "gc/FreeOp.h"
 #include "vm/GlobalObject.h"
 #include "vm/JSContext.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 
 #include "vm/JSObject-inl.h"
 #include "vm/NativeObject-inl.h"
 
 using namespace js;
 
 using mozilla::AssertedCast;
 
--- a/js/src/builtin/intl/SharedIntlData.cpp
+++ b/js/src/builtin/intl/SharedIntlData.cpp
@@ -8,21 +8,22 @@
 
 #include "builtin/intl/SharedIntlData.h"
 
 #include "mozilla/Assertions.h"
 #include "mozilla/HashFunctions.h"
 
 #include <stdint.h>
 
+#include "jsstr.h"
+
 #include "builtin/intl/CommonFunctions.h"
 #include "builtin/intl/ICUStubs.h"
 #include "builtin/intl/ScopedICUObject.h"
 #include "builtin/intl/TimeZoneDataGenerated.h"
-#include "builtin/String.h"
 #include "js/Utility.h"
 #include "vm/JSAtom.h"
 
 using js::HashNumber;
 using js::intl::StringsAreEqual;
 
 template<typename Char>
 static constexpr Char
--- a/js/src/builtin/intl/SharedIntlData.h
+++ b/js/src/builtin/intl/SharedIntlData.h
@@ -12,17 +12,17 @@
 #include <stddef.h>
 
 #include "js/AllocPolicy.h"
 #include "js/CharacterEncoding.h"
 #include "js/GCAPI.h"
 #include "js/GCHashTable.h"
 #include "js/RootingAPI.h"
 #include "js/Utility.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 
 namespace js {
 
 namespace intl {
 
 /**
  * Stores Intl data which can be shared across compartments (but not contexts).
  *
--- a/js/src/ctypes/CTypes.cpp
+++ b/js/src/ctypes/CTypes.cpp
@@ -23,18 +23,18 @@
 #ifdef HAVE_SSIZE_T
 # include <sys/types.h>
 #endif
 #if defined(XP_UNIX)
 # include <errno.h>
 #endif
 
 #include "jsexn.h"
-
-#include "builtin/Number.h"
+#include "jsnum.h"
+
 #include "builtin/TypedObject.h"
 #include "ctypes/Library.h"
 #include "gc/FreeOp.h"
 #include "gc/Policy.h"
 #include "gc/Zone.h"
 #include "jit/AtomicOperations.h"
 #include "js/Vector.h"
 #include "util/Windows.h"
--- a/js/src/ctypes/CTypes.h
+++ b/js/src/ctypes/CTypes.h
@@ -12,17 +12,17 @@
 #include "ffi.h"
 #include "prlink.h"
 
 #include "ctypes/typedefs.h"
 #include "js/AllocPolicy.h"
 #include "js/GCHashTable.h"
 #include "js/UniquePtr.h"
 #include "js/Vector.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 
 namespace js {
 namespace ctypes {
 
 /*******************************************************************************
 ** Utility classes
 *******************************************************************************/
 
--- a/js/src/frontend/BytecodeCompiler.h
+++ b/js/src/frontend/BytecodeCompiler.h
@@ -7,17 +7,17 @@
 #ifndef frontend_BytecodeCompiler_h
 #define frontend_BytecodeCompiler_h
 
 #include "mozilla/Maybe.h"
 
 #include "NamespaceImports.h"
 
 #include "vm/Scope.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 #include "vm/TraceLogging.h"
 
 class JSLinearString;
 
 namespace js {
 
 class LazyScript;
 class LifoAlloc;
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -14,20 +14,20 @@
 #include "mozilla/DebugOnly.h"
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/PodOperations.h"
 
 #include <string.h>
 
 #include "jsapi.h"
+#include "jsnum.h"
 #include "jstypes.h"
 #include "jsutil.h"
 
-#include "builtin/Number.h"
 #include "ds/Nestable.h"
 #include "frontend/Parser.h"
 #include "frontend/TokenStream.h"
 #include "vm/BytecodeUtil.h"
 #include "vm/Debugger.h"
 #include "vm/GeneratorObject.h"
 #include "vm/JSAtom.h"
 #include "vm/JSContext.h"
--- a/js/src/frontend/FoldConstants.cpp
+++ b/js/src/frontend/FoldConstants.cpp
@@ -3,21 +3,21 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "frontend/FoldConstants.h"
 
 #include "mozilla/FloatingPoint.h"
 
+#include "jslibmath.h"
+
 #include "frontend/ParseNode.h"
 #include "frontend/Parser.h"
 #include "js/Conversions.h"
-#include "util/PortableMath.h"
-#include "vm/StringType.h"
 
 #include "vm/JSContext-inl.h"
 #include "vm/JSObject-inl.h"
 
 using namespace js;
 using namespace js::frontend;
 
 using mozilla::IsNaN;
@@ -1004,17 +1004,17 @@ ComputeBinary(ParseNodeKind kind, double
 
     if (kind == ParseNodeKind::Sub)
         return left - right;
 
     if (kind == ParseNodeKind::Star)
         return left * right;
 
     if (kind == ParseNodeKind::Mod)
-        return NumberMod(left, right);
+        return right == 0 ? GenericNaN() : js_fmod(left, right);
 
     if (kind == ParseNodeKind::Ursh)
         return ToUint32(left) >> (ToUint32(right) & 31);
 
     if (kind == ParseNodeKind::Div) {
         if (right == 0) {
 #if defined(XP_WIN)
             /* XXX MSVC miscompiles such that (NaN == 0) */
--- a/js/src/frontend/NameFunctions.cpp
+++ b/js/src/frontend/NameFunctions.cpp
@@ -7,18 +7,18 @@
 #include "frontend/NameFunctions.h"
 
 #include "mozilla/MemoryChecking.h"
 #include "mozilla/Sprintf.h"
 
 #include "frontend/BytecodeCompiler.h"
 #include "frontend/ParseNode.h"
 #include "frontend/SharedContext.h"
-#include "util/StringBuffer.h"
 #include "vm/JSFunction.h"
+#include "vm/StringBuffer.h"
 
 using namespace js;
 using namespace js::frontend;
 
 namespace {
 
 class NameResolver
 {
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -33,17 +33,16 @@
 #include "frontend/TokenStream.h"
 #include "irregexp/RegExpParser.h"
 #include "vm/BytecodeUtil.h"
 #include "vm/JSAtom.h"
 #include "vm/JSContext.h"
 #include "vm/JSFunction.h"
 #include "vm/JSScript.h"
 #include "vm/RegExpObject.h"
-#include "vm/StringType.h"
 #include "wasm/AsmJS.h"
 
 #include "frontend/ParseContext-inl.h"
 #include "frontend/ParseNode-inl.h"
 #include "vm/EnvironmentObject-inl.h"
 #include "vm/JSAtom-inl.h"
 #include "vm/JSScript-inl.h"
 
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -14,29 +14,29 @@
 #include "mozilla/ScopeExit.h"
 
 #include <ctype.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
 
 #include "jsexn.h"
+#include "jsnum.h"
 
-#include "builtin/Number.h"
 #include "frontend/BytecodeCompiler.h"
 #include "frontend/Parser.h"
 #include "frontend/ReservedWords.h"
 #include "js/CharacterEncoding.h"
 #include "js/UniquePtr.h"
-#include "util/StringBuffer.h"
-#include "util/Unicode.h"
 #include "vm/HelperThreads.h"
 #include "vm/JSAtom.h"
 #include "vm/JSCompartment.h"
 #include "vm/JSContext.h"
+#include "vm/StringBuffer.h"
+#include "vm/Unicode.h"
 
 using mozilla::ArrayLength;
 using mozilla::MakeScopeExit;
 using mozilla::PodArrayZero;
 using mozilla::PodCopy;
 
 struct ReservedWordInfo
 {
--- a/js/src/frontend/TokenStream.h
+++ b/js/src/frontend/TokenStream.h
@@ -173,21 +173,21 @@
 #include <stdio.h>
 
 #include "jspubtd.h"
 
 #include "frontend/ErrorReporter.h"
 #include "frontend/TokenKind.h"
 #include "js/UniquePtr.h"
 #include "js/Vector.h"
-#include "util/Unicode.h"
 #include "vm/ErrorReporting.h"
 #include "vm/JSContext.h"
 #include "vm/RegExpShared.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
+#include "vm/Unicode.h"
 
 struct KeywordInfo;
 
 namespace js {
 namespace frontend {
 
 struct TokenPos {
     uint32_t    begin;  // Offset of the token's first char.
--- a/js/src/gc/Allocator.cpp
+++ b/js/src/gc/Allocator.cpp
@@ -8,17 +8,17 @@
 
 #include "gc/GCInternals.h"
 #include "gc/GCTrace.h"
 #include "gc/Nursery.h"
 #include "jit/JitCompartment.h"
 #include "threading/CpuCount.h"
 #include "vm/JSContext.h"
 #include "vm/Runtime.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 
 #include "gc/ArenaList-inl.h"
 #include "gc/Heap-inl.h"
 #include "gc/PrivateIterators-inl.h"
 #include "vm/JSObject-inl.h"
 
 using namespace js;
 using namespace gc;
--- a/js/src/gc/AtomMarking.h
+++ b/js/src/gc/AtomMarking.h
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef gc_AtomMarking_h
 #define gc_AtomMarking_h
 
 #include "NamespaceImports.h"
 #include "ds/Bitmap.h"
 #include "threading/ProtectedData.h"
-#include "vm/SymbolType.h"
+#include "vm/Symbol.h"
 
 namespace js {
 namespace gc {
 
 class Arena;
 
 // This class manages state used for marking atoms during GCs.
 // See AtomMarking.cpp for details.
--- a/js/src/gc/Barrier.cpp
+++ b/js/src/gc/Barrier.cpp
@@ -10,17 +10,17 @@
 #include "gc/Policy.h"
 #include "gc/Zone.h"
 #include "js/HashTable.h"
 #include "js/Value.h"
 #include "vm/EnvironmentObject.h"
 #include "vm/JSCompartment.h"
 #include "vm/JSObject.h"
 #include "vm/SharedArrayObject.h"
-#include "vm/SymbolType.h"
+#include "vm/Symbol.h"
 #include "wasm/WasmJS.h"
 
 namespace js {
 
 bool
 RuntimeFromActiveCooperatingThreadIsHeapMajorCollecting(JS::shadow::Zone* shadowZone)
 {
     MOZ_ASSERT(CurrentThreadCanAccessRuntime(shadowZone->runtimeFromActiveCooperatingThread()));
--- a/js/src/gc/GC.cpp
+++ b/js/src/gc/GC.cpp
@@ -228,31 +228,31 @@
 #include "vm/JSAtom.h"
 #include "vm/JSCompartment.h"
 #include "vm/JSContext.h"
 #include "vm/JSObject.h"
 #include "vm/JSScript.h"
 #include "vm/Printer.h"
 #include "vm/ProxyObject.h"
 #include "vm/Shape.h"
-#include "vm/StringType.h"
-#include "vm/SymbolType.h"
+#include "vm/String.h"
+#include "vm/Symbol.h"
 #include "vm/Time.h"
 #include "vm/TraceLogging.h"
 #include "vm/WrapperObject.h"
 
 #include "gc/Heap-inl.h"
 #include "gc/Marking-inl.h"
 #include "gc/Nursery-inl.h"
 #include "gc/PrivateIterators-inl.h"
 #include "vm/GeckoProfiler-inl.h"
 #include "vm/JSObject-inl.h"
 #include "vm/JSScript-inl.h"
 #include "vm/Stack-inl.h"
-#include "vm/StringType-inl.h"
+#include "vm/String-inl.h"
 
 using namespace js;
 using namespace js::gc;
 
 using mozilla::ArrayLength;
 using mozilla::Maybe;
 using mozilla::Move;
 using mozilla::Swap;
--- a/js/src/gc/Marking.cpp
+++ b/js/src/gc/Marking.cpp
@@ -22,27 +22,27 @@
 #include "vm/ArgumentsObject.h"
 #include "vm/ArrayObject.h"
 #include "vm/Debugger.h"
 #include "vm/EnvironmentObject.h"
 #include "vm/RegExpObject.h"
 #include "vm/RegExpShared.h"
 #include "vm/Scope.h"
 #include "vm/Shape.h"
-#include "vm/SymbolType.h"
+#include "vm/Symbol.h"
 #include "vm/TypedArrayObject.h"
 #include "vm/UnboxedObject.h"
 #include "wasm/WasmJS.h"
 
 #include "gc/GC-inl.h"
 #include "gc/Nursery-inl.h"
 #include "gc/PrivateIterators-inl.h"
 #include "vm/JSCompartment-inl.h"
 #include "vm/NativeObject-inl.h"
-#include "vm/StringType-inl.h"
+#include "vm/String-inl.h"
 #include "vm/UnboxedObject-inl.h"
 
 using namespace js;
 using namespace js::gc;
 
 using JS::MapTypeToTraceKind;
 
 using mozilla::DebugOnly;
--- a/js/src/gc/RootMarking.cpp
+++ b/js/src/gc/RootMarking.cpp
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifdef MOZ_VALGRIND
 # include <valgrind/memcheck.h>
 #endif
 
 #include "jstypes.h"
 
-#include "builtin/Map.h"
+#include "builtin/MapObject.h"
 #include "frontend/BytecodeCompiler.h"
 #include "gc/GCInternals.h"
 #include "gc/Marking.h"
 #include "jit/MacroAssembler.h"
 #include "js/HashTable.h"
 #include "vm/Debugger.h"
 #include "vm/JSContext.h"
 #include "vm/JSONParser.h"
--- a/js/src/gc/Statistics.cpp
+++ b/js/src/gc/Statistics.cpp
@@ -15,17 +15,16 @@
 #include <ctype.h>
 #include <stdarg.h>
 #include <stdio.h>
 
 #include "jsutil.h"
 
 #include "gc/GC.h"
 #include "gc/Memory.h"
-#include "util/Text.h"
 #include "vm/Debugger.h"
 #include "vm/HelperThreads.h"
 #include "vm/Runtime.h"
 #include "vm/Time.h"
 
 using namespace js;
 using namespace js::gc;
 using namespace js::gcstats;
--- a/js/src/gc/Tracer.cpp
+++ b/js/src/gc/Tracer.cpp
@@ -10,21 +10,20 @@
 
 #include "jsutil.h"
 #include "NamespaceImports.h"
 
 #include "gc/GCInternals.h"
 #include "gc/Marking.h"
 #include "gc/PublicIterators.h"
 #include "gc/Zone.h"
-#include "util/Text.h"
 #include "vm/JSFunction.h"
 #include "vm/JSScript.h"
 #include "vm/Shape.h"
-#include "vm/SymbolType.h"
+#include "vm/Symbol.h"
 
 #include "gc/GC-inl.h"
 #include "vm/JSCompartment-inl.h"
 #include "vm/ObjectGroup-inl.h"
 
 using namespace js;
 using namespace js::gc;
 using mozilla::DebugOnly;
--- a/js/src/gdb/tests/test-JSString.cpp
+++ b/js/src/gdb/tests/test-JSString.cpp
@@ -1,14 +1,14 @@
 #include "gdb-tests.h"
 
 #include "vm/JSContext.h"
 // When JSGC_ANALYSIS is #defined, Rooted<JSFlatString*> needs the definition
 // of JSFlatString in order to figure out its ThingRootKind
-#include "vm/StringType.h"
+#include "vm/String.h"
 
 FRAGMENT(JSString, simple) {
   AutoSuppressHazardsForTest noanalysis;
 
   JS::Rooted<JSString*> empty(cx, JS_NewStringCopyN(cx, nullptr, 0));
   JS::Rooted<JSString*> x(cx, JS_NewStringCopyN(cx, "x", 1));
   JS::Rooted<JSString*> z(cx, JS_NewStringCopyZ(cx, "z"));
 
--- a/js/src/irregexp/RegExpParser.cpp
+++ b/js/src/irregexp/RegExpParser.cpp
@@ -31,18 +31,18 @@
 #include "irregexp/RegExpParser.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Move.h"
 
 #include "frontend/TokenStream.h"
 #include "gc/GC.h"
 #include "irregexp/RegExpCharacters.h"
-#include "util/StringBuffer.h"
 #include "vm/ErrorReporting.h"
+#include "vm/StringBuffer.h"
 
 using namespace js;
 using namespace js::irregexp;
 
 using mozilla::Move;
 using mozilla::PointerRangeSize;
 
 // ----------------------------------------------------------------------------
--- a/js/src/jit/BaselineIC.cpp
+++ b/js/src/jit/BaselineIC.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jit/BaselineIC.h"
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/TemplateLib.h"
 
 #include "jsfriendapi.h"
+#include "jslibmath.h"
 #include "jstypes.h"
 
 #include "builtin/Eval.h"
 #include "builtin/SIMD.h"
 #include "gc/Policy.h"
 #include "jit/BaselineCacheIRCompiler.h"
 #include "jit/BaselineDebugModeOSR.h"
 #include "jit/BaselineJIT.h"
@@ -24,23 +25,22 @@
 #include "jit/Lowering.h"
 #ifdef JS_ION_PERF
 # include "jit/PerfSpewer.h"
 #endif
 #include "jit/SharedICHelpers.h"
 #include "jit/VMFunctions.h"
 #include "js/Conversions.h"
 #include "js/GCVector.h"
-#include "util/PortableMath.h"
 #include "vm/JSFunction.h"
 #include "vm/Opcodes.h"
 #include "vm/SelfHosting.h"
 #include "vm/TypedArrayObject.h"
 
-#include "builtin/Boolean-inl.h"
+#include "jsboolinlines.h"
 
 #include "jit/JitFrames-inl.h"
 #include "jit/MacroAssembler-inl.h"
 #include "jit/shared/Lowering-shared-inl.h"
 #include "jit/SharedICHelpers-inl.h"
 #include "vm/EnvironmentObject-inl.h"
 #include "vm/Interpreter-inl.h"
 #include "vm/JSScript-inl.h"
--- a/js/src/jit/CacheIRCompiler.cpp
+++ b/js/src/jit/CacheIRCompiler.cpp
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jit/CacheIRCompiler.h"
 
 #include "jit/IonIC.h"
 #include "jit/SharedICHelpers.h"
 
-#include "builtin/Boolean-inl.h"
+#include "jsboolinlines.h"
 
 #include "jit/MacroAssembler-inl.h"
 #include "vm/JSCompartment-inl.h"
 
 using namespace js;
 using namespace js::jit;
 
 ValueOperand
--- a/js/src/jit/CodeGenerator.cpp
+++ b/js/src/jit/CodeGenerator.cpp
@@ -13,22 +13,24 @@
 #include "mozilla/EnumeratedArray.h"
 #include "mozilla/EnumeratedRange.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/ScopeExit.h"
 #include "mozilla/Unused.h"
 
 #include <type_traits>
 
+#include "jslibmath.h"
+#include "jsmath.h"
+#include "jsnum.h"
+#include "jsstr.h"
+
 #include "builtin/Eval.h"
-#include "builtin/Math.h"
-#include "builtin/Number.h"
 #include "builtin/RegExp.h"
 #include "builtin/SelfHostingDefines.h"
-#include "builtin/String.h"
 #include "builtin/TypedObject.h"
 #include "gc/Nursery.h"
 #include "irregexp/NativeRegExpMacroAssembler.h"
 #include "jit/AtomicOperations.h"
 #include "jit/BaselineCompiler.h"
 #include "jit/IonBuilder.h"
 #include "jit/IonIC.h"
 #include "jit/IonOptimizationLevels.h"
@@ -36,29 +38,28 @@
 #include "jit/JitSpewer.h"
 #include "jit/Linker.h"
 #include "jit/Lowering.h"
 #include "jit/MIRGenerator.h"
 #include "jit/MoveEmitter.h"
 #include "jit/RangeAnalysis.h"
 #include "jit/SharedICHelpers.h"
 #include "jit/StackSlotAllocator.h"
-#include "util/PortableMath.h"
-#include "util/Unicode.h"
 #include "vm/AsyncFunction.h"
 #include "vm/AsyncIteration.h"
 #include "vm/MatchPairs.h"
 #include "vm/RegExpObject.h"
 #include "vm/RegExpStatics.h"
-#include "vm/StringType.h"
 #include "vm/TraceLogging.h"
 #include "vm/TypedArrayObject.h"
+#include "vm/Unicode.h"
 #include "vtune/VTuneWrapper.h"
 
-#include "builtin/Boolean-inl.h"
+#include "jsboolinlines.h"
+
 #include "jit/MacroAssembler-inl.h"
 #include "jit/shared/CodeGenerator-shared-inl.h"
 #include "jit/shared/Lowering-shared-inl.h"
 #include "vm/Interpreter-inl.h"
 
 using namespace js;
 using namespace js::jit;
 
--- a/js/src/jit/EffectiveAddressAnalysis.cpp
+++ b/js/src/jit/EffectiveAddressAnalysis.cpp
@@ -1,21 +1,21 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jit/EffectiveAddressAnalysis.h"
 
-#include "builtin/Number.h"
+#include "jsnum.h"
+
 #include "jit/IonAnalysis.h"
 #include "jit/MIR.h"
 #include "jit/MIRGraph.h"
-#include "util/PortableMath.h"
 
 using namespace js;
 using namespace jit;
 
 static void
 AnalyzeLsh(TempAllocator& alloc, MLsh* lsh)
 {
     if (lsh->specialization() != MIRType::Int32)
--- a/js/src/jit/IonAnalysis.cpp
+++ b/js/src/jit/IonAnalysis.cpp
@@ -11,17 +11,16 @@
 #include "jit/BaselineJIT.h"
 #include "jit/FlowAliasAnalysis.h"
 #include "jit/Ion.h"
 #include "jit/IonBuilder.h"
 #include "jit/IonOptimizationLevels.h"
 #include "jit/LIR.h"
 #include "jit/Lowering.h"
 #include "jit/MIRGraph.h"
-#include "util/PortableMath.h"
 #include "vm/RegExpObject.h"
 #include "vm/SelfHosting.h"
 
 #include "jit/shared/Lowering-shared-inl.h"
 #include "vm/BytecodeUtil-inl.h"
 #include "vm/JSObject-inl.h"
 #include "vm/JSScript-inl.h"
 
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -15,17 +15,16 @@
 #include "jit/BaselineFrame.h"
 #include "jit/BaselineInspector.h"
 #include "jit/Ion.h"
 #include "jit/IonControlFlow.h"
 #include "jit/IonOptimizationLevels.h"
 #include "jit/JitSpewer.h"
 #include "jit/Lowering.h"
 #include "jit/MIRGraph.h"
-#include "util/PortableMath.h"
 #include "vm/ArgumentsObject.h"
 #include "vm/Opcodes.h"
 #include "vm/RegExpStatics.h"
 #include "vm/TraceLogging.h"
 
 #include "gc/Nursery-inl.h"
 #include "jit/CompileInfo-inl.h"
 #include "jit/shared/Lowering-shared-inl.h"
--- a/js/src/jit/IonTypes.h
+++ b/js/src/jit/IonTypes.h
@@ -10,17 +10,17 @@
 #include "mozilla/HashFunctions.h"
 
 #include <algorithm>
 
 #include "jsfriendapi.h"
 #include "jstypes.h"
 
 #include "js/Value.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 
 namespace js {
 namespace jit {
 
 typedef uint32_t RecoverOffset;
 typedef uint32_t SnapshotOffset;
 typedef uint32_t BailoutId;
 
--- a/js/src/jit/MCallOptimize.cpp
+++ b/js/src/jit/MCallOptimize.cpp
@@ -1,26 +1,27 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Casting.h"
 
-#include "builtin/Atomics.h"
+#include "jsmath.h"
+#include "jsstr.h"
+
+#include "builtin/AtomicsObject.h"
 #include "builtin/intl/Collator.h"
 #include "builtin/intl/DateTimeFormat.h"
 #include "builtin/intl/NumberFormat.h"
 #include "builtin/intl/PluralRules.h"
 #include "builtin/intl/RelativeTimeFormat.h"
-#include "builtin/Map.h"
-#include "builtin/Math.h"
+#include "builtin/MapObject.h"
 #include "builtin/SIMD.h"
-#include "builtin/String.h"
 #include "builtin/TestingFunctions.h"
 #include "builtin/TypedObject.h"
 #include "jit/BaselineInspector.h"
 #include "jit/InlinableNatives.h"
 #include "jit/IonBuilder.h"
 #include "jit/Lowering.h"
 #include "jit/MIR.h"
 #include "jit/MIRGraph.h"
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -9,29 +9,30 @@
 #include "mozilla/CheckedInt.h"
 #include "mozilla/EndianUtils.h"
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/MathAlgorithms.h"
 
 #include <ctype.h>
 
+#include "jslibmath.h"
+#include "jsstr.h"
+
 #include "builtin/RegExp.h"
-#include "builtin/String.h"
 #include "jit/AtomicOperations.h"
 #include "jit/BaselineInspector.h"
 #include "jit/IonBuilder.h"
 #include "jit/JitSpewer.h"
 #include "jit/MIRGraph.h"
 #include "jit/RangeAnalysis.h"
 #include "js/Conversions.h"
-#include "util/PortableMath.h"
-#include "util/Text.h"
-
-#include "builtin/Boolean-inl.h"
+
+#include "jsboolinlines.h"
+
 #include "vm/JSAtom-inl.h"
 #include "vm/JSObject-inl.h"
 #include "vm/JSScript-inl.h"
 #include "vm/UnboxedObject-inl.h"
 
 using namespace js;
 using namespace js::jit;
 
--- a/js/src/jit/OptimizationTracking.cpp
+++ b/js/src/jit/OptimizationTracking.cpp
@@ -6,17 +6,16 @@
 
 #include "jit/OptimizationTracking.h"
 
 #include "ds/Sort.h"
 #include "jit/IonBuilder.h"
 #include "jit/JitcodeMap.h"
 #include "jit/JitSpewer.h"
 #include "js/TrackedOptimizationInfo.h"
-#include "util/Text.h"
 
 #include "vm/ObjectGroup-inl.h"
 #include "vm/TypeInference-inl.h"
 
 using namespace js;
 using namespace js::jit;
 
 using mozilla::Maybe;
--- a/js/src/jit/ProcessExecutableMemory.cpp
+++ b/js/src/jit/ProcessExecutableMemory.cpp
@@ -11,19 +11,19 @@
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/TaggedAnonymousMemory.h"
 #include "mozilla/XorShift128PlusRNG.h"
 
 #include <errno.h>
 
 #include "jsfriendapi.h"
+#include "jsmath.h"
 #include "jsutil.h"
 
-#include "builtin/Math.h"
 #include "gc/Memory.h"
 #include "threading/LockGuard.h"
 #include "threading/Mutex.h"
 #include "util/Windows.h"
 #include "vm/MutexIDs.h"
 
 #ifdef XP_WIN
 # include "mozilla/StackWalk_windows.h"
--- a/js/src/jit/RangeAnalysis.cpp
+++ b/js/src/jit/RangeAnalysis.cpp
@@ -10,17 +10,16 @@
 
 #include "jit/Ion.h"
 #include "jit/IonAnalysis.h"
 #include "jit/JitSpewer.h"
 #include "jit/MIR.h"
 #include "jit/MIRGenerator.h"
 #include "jit/MIRGraph.h"
 #include "js/Conversions.h"
-#include "util/PortableMath.h"
 #include "vm/ArgumentsObject.h"
 #include "vm/TypedArrayObject.h"
 
 #include "vm/BytecodeUtil-inl.h"
 
 using namespace js;
 using namespace js::jit;
 
--- a/js/src/jit/Recover.cpp
+++ b/js/src/jit/Recover.cpp
@@ -2,33 +2,33 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jit/Recover.h"
 
 #include "jsapi.h"
+#include "jsmath.h"
+#include "jsstr.h"
 
-#include "builtin/Math.h"
 #include "builtin/RegExp.h"
 #include "builtin/SIMD.h"
-#include "builtin/String.h"
 #include "builtin/TypedObject.h"
 #include "gc/Heap.h"
 #include "jit/JitSpewer.h"
 #include "jit/JSJitFrameIter.h"
 #include "jit/MIR.h"
 #include "jit/MIRGraph.h"
 #include "jit/VMFunctions.h"
 #include "vm/Interpreter.h"
 #include "vm/Iteration.h"
 #include "vm/JSContext.h"
 #include "vm/JSObject.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 
 #include "vm/Interpreter-inl.h"
 #include "vm/NativeObject-inl.h"
 
 using namespace js;
 using namespace js::jit;
 
 bool
--- a/js/src/jit/Recover.h
+++ b/js/src/jit/Recover.h
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef jit_Recover_h
 #define jit_Recover_h
 
 #include "mozilla/Attributes.h"
 
-#include "builtin/Array.h"
+#include "jsarray.h"
 
 #include "jit/MIR.h"
 #include "jit/Snapshots.h"
 
 namespace js {
 namespace jit {
 
 // This file contains all recover instructions.
--- a/js/src/jit/SharedIC.cpp
+++ b/js/src/jit/SharedIC.cpp
@@ -5,32 +5,31 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jit/SharedIC.h"
 
 #include "mozilla/Casting.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Sprintf.h"
 
+#include "jslibmath.h"
 #include "jstypes.h"
 
 #include "gc/Policy.h"
 #include "jit/BaselineCacheIRCompiler.h"
 #include "jit/BaselineDebugModeOSR.h"
 #include "jit/BaselineIC.h"
 #include "jit/JitSpewer.h"
 #include "jit/Linker.h"
 #include "jit/SharedICHelpers.h"
 #ifdef JS_ION_PERF
 # include "jit/PerfSpewer.h"
 #endif
 #include "jit/VMFunctions.h"
-#include "util/PortableMath.h"
 #include "vm/Interpreter.h"
-#include "vm/StringType.h"
 
 #include "jit/MacroAssembler-inl.h"
 #include "jit/SharedICHelpers-inl.h"
 #include "vm/Interpreter-inl.h"
 
 using mozilla::BitwiseCast;
 
 namespace js {
--- a/js/src/jit/arm/CodeGenerator-arm.cpp
+++ b/js/src/jit/arm/CodeGenerator-arm.cpp
@@ -5,17 +5,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jit/arm/CodeGenerator-arm.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/Maybe.h"
 
-#include "builtin/Number.h"
+#include "jsnum.h"
+
 #include "jit/CodeGenerator.h"
 #include "jit/JitCompartment.h"
 #include "jit/JitFrames.h"
 #include "jit/MIR.h"
 #include "jit/MIRGraph.h"
 #include "js/Conversions.h"
 #include "vm/JSCompartment.h"
 #include "vm/JSContext.h"
--- a/js/src/jit/arm64/CodeGenerator-arm64.cpp
+++ b/js/src/jit/arm64/CodeGenerator-arm64.cpp
@@ -3,17 +3,18 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jit/arm64/CodeGenerator-arm64.h"
 
 #include "mozilla/MathAlgorithms.h"
 
-#include "builtin/Number.h"
+#include "jsnum.h"
+
 #include "jit/CodeGenerator.h"
 #include "jit/JitCompartment.h"
 #include "jit/JitFrames.h"
 #include "jit/MIR.h"
 #include "jit/MIRGraph.h"
 #include "vm/JSCompartment.h"
 #include "vm/JSContext.h"
 #include "vm/Shape.h"
--- a/js/src/jit/mips-shared/AtomicOperations-mips-shared.h
+++ b/js/src/jit/mips-shared/AtomicOperations-mips-shared.h
@@ -14,17 +14,17 @@
 // whose instance is shared between jit and AtomicOperations.
 
 #ifndef jit_mips_shared_AtomicOperations_mips_shared_h
 #define jit_mips_shared_AtomicOperations_mips_shared_h
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Types.h"
 
-#include "builtin/Atomics.h"
+#include "builtin/AtomicsObject.h"
 #include "vm/ArrayBufferObject.h"
 
 #if !defined(__clang__) && !defined(__GNUC__)
 # error "This file only for gcc-compatible compilers"
 #endif
 
 #if defined(JS_SIMULATOR_MIPS32) && !defined(__i386__)
 # error "The MIPS32 simulator atomics assume x86"
--- a/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp
+++ b/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp
@@ -4,17 +4,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jit/mips-shared/CodeGenerator-mips-shared.h"
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/MathAlgorithms.h"
 
-#include "builtin/Number.h"
+#include "jsnum.h"
+
 #include "jit/CodeGenerator.h"
 #include "jit/JitCompartment.h"
 #include "jit/JitFrames.h"
 #include "jit/MIR.h"
 #include "jit/MIRGraph.h"
 #include "js/Conversions.h"
 #include "vm/JSCompartment.h"
 #include "vm/JSContext.h"
--- a/js/src/jit/mips32/SharedIC-mips32.cpp
+++ b/js/src/jit/mips32/SharedIC-mips32.cpp
@@ -6,17 +6,17 @@
 
 #include "jit/BaselineCompiler.h"
 #include "jit/BaselineIC.h"
 #include "jit/BaselineJIT.h"
 #include "jit/Linker.h"
 #include "jit/SharedICHelpers.h"
 #include "vm/Iteration.h"
 
-#include "builtin/Boolean-inl.h"
+#include "jsboolinlines.h"
 
 using namespace js;
 using namespace js::jit;
 
 namespace js {
 namespace jit {
 
 // ICBinaryArith_Int32
--- a/js/src/jit/mips64/SharedIC-mips64.cpp
+++ b/js/src/jit/mips64/SharedIC-mips64.cpp
@@ -6,17 +6,17 @@
 
 #include "jit/BaselineCompiler.h"
 #include "jit/BaselineIC.h"
 #include "jit/BaselineJIT.h"
 #include "jit/Linker.h"
 #include "jit/SharedICHelpers.h"
 #include "vm/Iteration.h"
 
-#include "builtin/Boolean-inl.h"
+#include "jsboolinlines.h"
 
 using namespace js;
 using namespace js::jit;
 
 namespace js {
 namespace jit {
 
 // ICBinaryArith_Int32
--- a/js/src/jit/shared/Lowering-shared.cpp
+++ b/js/src/jit/shared/Lowering-shared.cpp
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jit/shared/Lowering-shared-inl.h"
 
 #include "jit/LIR.h"
 #include "jit/MIR.h"
 
-#include "vm/SymbolType.h"
+#include "vm/Symbol.h"
 
 using namespace js;
 using namespace jit;
 
 bool
 LIRGeneratorShared::ShouldReorderCommutative(MDefinition* lhs, MDefinition* rhs, MInstruction* ins)
 {
     // lhs and rhs are used by the commutative operator.
--- a/js/src/jit/x86-shared/CodeGenerator-x86-shared.cpp
+++ b/js/src/jit/x86-shared/CodeGenerator-x86-shared.cpp
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jit/x86-shared/CodeGenerator-x86-shared.h"
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/MathAlgorithms.h"
 
-#include "builtin/Math.h"
+#include "jsmath.h"
 
 #include "jit/JitCompartment.h"
 #include "jit/JitFrames.h"
 #include "jit/Linker.h"
 #include "jit/RangeAnalysis.h"
 #include "vm/TraceLogging.h"
 
 #include "jit/MacroAssembler-inl.h"
--- a/js/src/jit/x86/CodeGenerator-x86.cpp
+++ b/js/src/jit/x86/CodeGenerator-x86.cpp
@@ -5,17 +5,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jit/x86/CodeGenerator-x86.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Casting.h"
 #include "mozilla/DebugOnly.h"
 
-#include "builtin/Number.h"
+#include "jsnum.h"
+
 #include "jit/MIR.h"
 #include "jit/MIRGraph.h"
 #include "js/Conversions.h"
 #include "vm/Shape.h"
 
 #include "jit/MacroAssembler-inl.h"
 #include "jit/shared/CodeGenerator-shared-inl.h"
 #include "vm/JSScript-inl.h"
--- a/js/src/jsapi-tests/testErrorInterceptor.cpp
+++ b/js/src/jsapi-tests/testErrorInterceptor.cpp
@@ -1,13 +1,13 @@
 #include "jsapi.h"
 
 #include "jsapi-tests/tests.h"
 
-#include "util/StringBuffer.h"
+#include "vm/StringBuffer.h"
 
 // Tests for JS_GetErrorInterceptorCallback and JS_SetErrorInterceptorCallback.
 
 
 namespace {
 const double EXN_VALUE = 3.14;
 
 static JS::PersistentRootedString gLatestMessage;
--- a/js/src/jsapi-tests/testIndexToString.cpp
+++ b/js/src/jsapi-tests/testIndexToString.cpp
@@ -1,22 +1,23 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "builtin/Number.h"
-#include "builtin/String.h"
+#include "jsnum.h"
+#include "jsstr.h"
+
 #include "jsapi-tests/tests.h"
 #include "vm/JSCompartment.h"
 #include "vm/JSContext.h"
 
-#include "vm/StringType-inl.h"
+#include "vm/String-inl.h"
 
 using mozilla::ArrayLength;
 
 static const struct TestPair {
     uint32_t num;
     const char* expected;
 } tests[] = {
     { 0, "0" },
--- a/js/src/jsapi-tests/testIntern.cpp
+++ b/js/src/jsapi-tests/testIntern.cpp
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "gc/FreeOp.h"
 #include "gc/Marking.h"
 #include "jsapi-tests/tests.h"
 #include "vm/JSAtom.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 
 using mozilla::ArrayLength;
 
 BEGIN_TEST(testAtomizedIsNotPinned)
 {
     /* Try to pick a string that won't be interned by other tests in this runtime. */
     static const char someChars[] = "blah blah blah? blah blah blah";
     JS::Rooted<JSAtom*> atom(cx, js::Atomize(cx, someChars, ArrayLength(someChars)));
--- a/js/src/jsapi-tests/testParseJSON.cpp
+++ b/js/src/jsapi-tests/testParseJSON.cpp
@@ -3,17 +3,17 @@
  */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <limits>
 #include <string.h>
 
-#include "builtin/String.h"
+#include "jsstr.h"
 
 #include "js/Printf.h"
 #include "jsapi-tests/tests.h"
 
 using namespace js;
 
 class AutoInflatedString {
     JSContext * const cx;
--- a/js/src/jsapi-tests/testSavedStacks.cpp
+++ b/js/src/jsapi-tests/testSavedStacks.cpp
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jsfriendapi.h"
-#include "builtin/String.h"
+#include "jsstr.h"
 
 #include "builtin/TestingFunctions.h"
 #include "jsapi-tests/tests.h"
 #include "vm/ArrayObject.h"
 #include "vm/JSCompartment.h"
 #include "vm/SavedStacks.h"
 
 BEGIN_TEST(testSavedStacks_withNoStack)
--- a/js/src/jsapi-tests/testSharedImmutableStringsCache.cpp
+++ b/js/src/jsapi-tests/testSharedImmutableStringsCache.cpp
@@ -4,17 +4,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/IntegerRange.h"
 
 #include "js/Vector.h"
 #include "jsapi-tests/tests.h"
 #include "threading/Thread.h"
-#include "util/Text.h"
 #include "vm/SharedImmutableStringsCache.h"
 
 const int NUM_THREADS = 256;
 const int NUM_ITERATIONS = 256;
 
 const int NUM_STRINGS = 4;
 const char16_t *const STRINGS[NUM_STRINGS] = {
     u"uno",
--- a/js/src/jsapi-tests/testStringBuffer.cpp
+++ b/js/src/jsapi-tests/testStringBuffer.cpp
@@ -1,18 +1,18 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jsapi-tests/tests.h"
-#include "util/StringBuffer.h"
 #include "vm/JSAtom.h"
+#include "vm/StringBuffer.h"
 
 BEGIN_TEST(testStringBuffer_finishString)
 {
     JSString* str = JS_NewStringCopyZ(cx, "foopy");
     CHECK(str);
 
     JS::Rooted<JSAtom*> atom(cx, js::AtomizeString(cx, str));
     CHECK(atom);
--- a/js/src/jsapi-tests/testUTF8.cpp
+++ b/js/src/jsapi-tests/testUTF8.cpp
@@ -3,17 +3,17 @@
  */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Range.h"
 
 #include "jsapi.h"
-#include "builtin/String.h"
+#include "jsstr.h"
 
 #include "js/CharacterEncoding.h"
 #include "jsapi-tests/tests.h"
 
 BEGIN_TEST(testUTF8_badUTF8)
 {
     static const char badUTF8[] = "...\xC0...";
     JSString* str = JS_NewStringCopyZ(cx, badUTF8);
--- a/js/src/jsapi-tests/testUbiNode.cpp
+++ b/js/src/jsapi-tests/testUbiNode.cpp
@@ -3,17 +3,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "builtin/TestingFunctions.h"
 #include "js/UbiNode.h"
 #include "js/UbiNodeDominatorTree.h"
 #include "js/UbiNodePostOrder.h"
 #include "js/UbiNodeShortestPaths.h"
 #include "jsapi-tests/tests.h"
-#include "util/Text.h"
 #include "vm/SavedFrame.h"
 
 using JS::RootedObject;
 using JS::RootedScript;
 using JS::RootedString;
 using namespace js;
 
 // A helper JS::ubi::Node concrete implementation that can be used to make mock
--- a/js/src/jsapi-tests/testXDR.cpp
+++ b/js/src/jsapi-tests/testXDR.cpp
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jsfriendapi.h"
-#include "builtin/String.h"
+#include "jsstr.h"
 
 #include "jsapi-tests/tests.h"
 #include "vm/JSScript.h"
 
 #include "vm/JSScript-inl.h"
 
 static bool
 GetBuildId(JS::BuildIdCharVector* buildId)
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -18,35 +18,35 @@
 #include <ctype.h>
 #ifdef __linux__
 # include <dlfcn.h>
 #endif
 #include <stdarg.h>
 #include <string.h>
 #include <sys/stat.h>
 
+#include "jsarray.h"
+#include "jsbool.h"
+#include "jsdate.h"
 #include "jsexn.h"
 #include "jsfriendapi.h"
+#include "jsmath.h"
+#include "jsnum.h"
+#include "jsstr.h"
 #include "jstypes.h"
 #include "jsutil.h"
 
-#include "builtin/Array.h"
-#include "builtin/Atomics.h"
-#include "builtin/Boolean.h"
-#include "builtin/Date.h"
+#include "builtin/AtomicsObject.h"
 #include "builtin/Eval.h"
 #include "builtin/JSON.h"
-#include "builtin/Map.h"
-#include "builtin/Math.h"
-#include "builtin/Number.h"
+#include "builtin/MapObject.h"
 #include "builtin/Promise.h"
 #include "builtin/RegExp.h"
 #include "builtin/Stream.h"
-#include "builtin/String.h"
-#include "builtin/Symbol.h"
+#include "builtin/SymbolObject.h"
 #ifdef ENABLE_SIMD
 # include "builtin/SIMD.h"
 #endif
 #ifdef ENABLE_BINARYDATA
 # include "builtin/TypedObject.h"
 #endif
 #include "frontend/BytecodeCompiler.h"
 #include "frontend/FullParseHandler.h"  // for JS_BufferIsCompileableUnit
@@ -61,18 +61,16 @@
 #include "js/Conversions.h"
 #include "js/Date.h"
 #include "js/Initialization.h"
 #include "js/Proxy.h"
 #include "js/SliceBudget.h"
 #include "js/StructuredClone.h"
 #include "js/Utility.h"
 #include "js/Wrapper.h"
-#include "util/StringBuffer.h"
-#include "util/Text.h"
 #include "vm/AsyncFunction.h"
 #include "vm/AsyncIteration.h"
 #include "vm/DateObject.h"
 #include "vm/Debugger.h"
 #include "vm/EnvironmentObject.h"
 #include "vm/ErrorObject.h"
 #include "vm/HelperThreads.h"
 #include "vm/Interpreter.h"
@@ -82,30 +80,31 @@
 #include "vm/JSFunction.h"
 #include "vm/JSObject.h"
 #include "vm/JSScript.h"
 #include "vm/RegExpStatics.h"
 #include "vm/Runtime.h"
 #include "vm/SavedStacks.h"
 #include "vm/SelfHosting.h"
 #include "vm/Shape.h"
-#include "vm/StringType.h"
-#include "vm/SymbolType.h"
+#include "vm/String.h"
+#include "vm/StringBuffer.h"
+#include "vm/Symbol.h"
 #include "vm/WrapperObject.h"
 #include "vm/Xdr.h"
 #include "wasm/AsmJS.h"
 #include "wasm/WasmModule.h"
 
 #include "vm/Interpreter-inl.h"
 #include "vm/JSAtom-inl.h"
 #include "vm/JSFunction-inl.h"
 #include "vm/JSScript-inl.h"
 #include "vm/NativeObject-inl.h"
 #include "vm/SavedStacks-inl.h"
-#include "vm/StringType-inl.h"
+#include "vm/String-inl.h"
 
 using namespace js;
 using namespace js::gc;
 
 using mozilla::Maybe;
 using mozilla::PodCopy;
 using mozilla::Some;
 
rename from js/src/builtin/Array.cpp
rename to js/src/jsarray.cpp
--- a/js/src/builtin/Array.cpp
+++ b/js/src/jsarray.cpp
@@ -1,45 +1,44 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "builtin/Array-inl.h"
+#include "jsarrayinlines.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/MathAlgorithms.h"
 
 #include <algorithm>
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
+#include "jsnum.h"
 #include "jstypes.h"
 #include "jsutil.h"
 
-#include "builtin/Number.h"
 #include "ds/Sort.h"
 #include "gc/Heap.h"
 #include "jit/InlinableNatives.h"
 #include "js/Class.h"
 #include "js/Conversions.h"
-#include "util/StringBuffer.h"
-#include "util/Text.h"
 #include "vm/ArgumentsObject.h"
 #include "vm/Interpreter.h"
 #include "vm/Iteration.h"
 #include "vm/JSAtom.h"
 #include "vm/JSContext.h"
 #include "vm/JSFunction.h"
 #include "vm/JSObject.h"
 #include "vm/SelfHosting.h"
 #include "vm/Shape.h"
+#include "vm/StringBuffer.h"
 #include "vm/TypedArrayObject.h"
 #include "vm/WrapperObject.h"
 
 #include "vm/ArgumentsObject-inl.h"
 #include "vm/ArrayObject-inl.h"
 #include "vm/Caches-inl.h"
 #include "vm/GeckoProfiler-inl.h"
 #include "vm/Interpreter-inl.h"
rename from js/src/builtin/Array.h
rename to js/src/jsarray.h
--- a/js/src/builtin/Array.h
+++ b/js/src/jsarray.h
@@ -1,18 +1,18 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* JS Array interface. */
 
-#ifndef builtin_Array_h
-#define builtin_Array_h
+#ifndef jsarray_h
+#define jsarray_h
 
 #include "jspubtd.h"
 
 #include "vm/ArrayObject.h"
 #include "vm/JSObject.h"
 
 namespace js {
 /* 2^32-2, inclusive */
@@ -275,9 +275,9 @@ class MOZ_NON_TEMPORARY_CLASS ArraySpeci
     void purge() {
         if (state_ == State::Initialized)
             reset();
     }
 };
 
 } /* namespace js */
 
-#endif /* builtin_Array_h */
+#endif /* jsarray_h */
rename from js/src/builtin/Array-inl.h
rename to js/src/jsarrayinlines.h
--- a/js/src/builtin/Array-inl.h
+++ b/js/src/jsarrayinlines.h
@@ -1,18 +1,18 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef builtin_Array_inl_h
-#define builtin_Array_inl_h
+#ifndef vm_jsarrayinlines_h
+#define vm_jsarrayinlines_h
 
-#include "builtin/Array.h"
+#include "jsarray.h"
 
 #include "vm/ArgumentsObject.h"
 #include "vm/JSObject.h"
 
 #include "vm/ArgumentsObject-inl.h"
 #include "vm/UnboxedObject-inl.h"
 
 namespace js {
@@ -31,9 +31,9 @@ GetElement(JSContext* cx, HandleObject o
             return true;
     }
 
     return GetElement(cx, obj, obj, index, vp);
 }
 
 } // namespace js
 
-#endif // builtin_Array_inl_h
+#endif // vm_jsarrayinlines_h
rename from js/src/builtin/Boolean.cpp
rename to js/src/jsbool.cpp
--- a/js/src/builtin/Boolean.cpp
+++ b/js/src/jsbool.cpp
@@ -3,28 +3,28 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * JS boolean implementation.
  */
 
-#include "builtin/Boolean-inl.h"
+#include "jsboolinlines.h"
 
 #include "jsapi.h"
 #include "jstypes.h"
 
 #include "jit/InlinableNatives.h"
-#include "util/StringBuffer.h"
 #include "vm/GlobalObject.h"
 #include "vm/JSAtom.h"
 #include "vm/JSContext.h"
 #include "vm/JSObject.h"
 #include "vm/ProxyObject.h"
+#include "vm/StringBuffer.h"
 
 #include "vm/BooleanObject-inl.h"
 
 using namespace js;
 
 const Class BooleanObject::class_ = {
     "Boolean",
     JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_HAS_CACHED_PROTO(JSProto_Boolean)
rename from js/src/builtin/Boolean.h
rename to js/src/jsbool.h
--- a/js/src/builtin/Boolean.h
+++ b/js/src/jsbool.h
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef builtin_Boolean_h
-#define builtin_Boolean_h
+#ifndef jsbool_h
+#define jsbool_h
 
 /*
  * JS boolean interface.
  */
 
 #include "NamespaceImports.h"
 
 namespace js {
@@ -18,9 +18,9 @@ namespace js {
 extern JSObject*
 InitBooleanClass(JSContext* cx, js::HandleObject obj);
 
 extern JSString*
 BooleanToString(JSContext* cx, bool b);
 
 } // namespace js
 
-#endif /* builtin_Boolean_h */
+#endif /* jsbool_h */
rename from js/src/builtin/Boolean-inl.h
rename to js/src/jsboolinlines.h
--- a/js/src/builtin/Boolean-inl.h
+++ b/js/src/jsboolinlines.h
@@ -1,18 +1,18 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef builtin_Boolean_inl_h
-#define builtin_Boolean_inl_h
+#ifndef jsboolinlines_h
+#define jsboolinlines_h
 
-#include "builtin/Boolean.h"
+#include "jsbool.h"
 
 #include "vm/BooleanObject.h"
 #include "vm/JSContext.h"
 #include "vm/WrapperObject.h"
 
 namespace js {
 
 inline bool
@@ -22,9 +22,9 @@ EmulatesUndefined(JSObject* obj)
     // here as it doesn't escape.
     AutoUnsafeCallWithABI unsafe;
     JSObject* actual = MOZ_LIKELY(!obj->is<WrapperObject>()) ? obj : UncheckedUnwrapWithoutExpose(obj);
     return actual->getClass()->emulatesUndefined();
 }
 
 } /* namespace js */
 
-#endif /* builtin_Boolean_inl_h */
+#endif /* jsboolinlines_h */
rename from js/src/builtin/Date.cpp
rename to js/src/jsdate.cpp
--- a/js/src/builtin/Date.cpp
+++ b/js/src/jsdate.cpp
@@ -10,42 +10,43 @@
  * "For example, OS/360 devotes 26 bytes of the permanently
  *  resident date-turnover routine to the proper handling of
  *  December 31 on leap years (when it is Day 366).  That
  *  might have been left to the operator."
  *
  * Frederick Brooks, 'The Second-System Effect'.
  */
 
-#include "builtin/Date.h"
+#include "jsdate.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/Sprintf.h"
 
 #include <ctype.h>
 #include <math.h>
 #include <string.h>
 
 #include "jsapi.h"
+#include "jsnum.h"
+#include "jsstr.h"
 #include "jstypes.h"
 #include "jsutil.h"
 
-#include "builtin/Number.h"
-#include "builtin/String.h"
 #include "js/Conversions.h"
+#include "js/Date.h"
 #include "js/Wrapper.h"
-#include "util/StringBuffer.h"
 #include "vm/DateTime.h"
 #include "vm/GlobalObject.h"
 #include "vm/Interpreter.h"
 #include "vm/JSContext.h"
 #include "vm/JSObject.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
+#include "vm/StringBuffer.h"
 #include "vm/Time.h"
 
 #include "vm/JSObject-inl.h"
 
 using namespace js;
 
 using mozilla::Atomic;
 using mozilla::ArrayLength;
rename from js/src/builtin/Date.h
rename to js/src/jsdate.h
--- a/js/src/builtin/Date.h
+++ b/js/src/jsdate.h
@@ -3,25 +3,25 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * JS Date class interface.
  */
 
-#ifndef builtin_Date_h
-#define builtin_Date_h
-
-#include "js/Date.h"
+#ifndef jsdate_h
+#define jsdate_h
 
 #include "jstypes.h"
 
+#include "js/Date.h"
 #include "js/RootingAPI.h"
 #include "js/TypeDecls.h"
+
 #include "vm/DateTime.h"
 
 namespace js {
 
 /*
  * These functions provide a C interface to the date/time object
  */
 
@@ -51,9 +51,9 @@ DateConstructor(JSContext* cx, unsigned 
 bool
 date_now(JSContext* cx, unsigned argc, JS::Value* vp);
 
 bool
 date_valueOf(JSContext* cx, unsigned argc, JS::Value* vp);
 
 } /* namespace js */
 
-#endif /* builtin_Date_h */
+#endif /* jsdate_h */
--- a/js/src/jsexn.cpp
+++ b/js/src/jsexn.cpp
@@ -10,34 +10,33 @@
 
 #include "jsexn.h"
 
 #include "mozilla/Sprintf.h"
 
 #include <string.h>
 
 #include "jsapi.h"
+#include "jsnum.h"
 #include "jstypes.h"
 #include "jsutil.h"
 
-#include "builtin/Number.h"
 #include "gc/FreeOp.h"
 #include "gc/Marking.h"
 #include "js/CharacterEncoding.h"
 #include "js/Wrapper.h"
-#include "util/StringBuffer.h"
 #include "vm/ErrorObject.h"
 #include "vm/GlobalObject.h"
 #include "vm/JSContext.h"
 #include "vm/JSFunction.h"
 #include "vm/JSObject.h"
 #include "vm/JSScript.h"
 #include "vm/SavedStacks.h"
 #include "vm/SelfHosting.h"
-#include "vm/StringType.h"
+#include "vm/StringBuffer.h"
 
 #include "vm/ErrorObject-inl.h"
 #include "vm/JSObject-inl.h"
 #include "vm/SavedStacks-inl.h"
 
 using namespace js;
 using namespace js::gc;
 
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -1381,17 +1381,17 @@ struct XrayJitInfo {
 };
 
 JS_FRIEND_API(void)
 SetXrayJitInfo(XrayJitInfo* info);
 
 XrayJitInfo*
 GetXrayJitInfo();
 
-/* Implemented in builtin/Date.cpp. */
+/* Implemented in jsdate.cpp. */
 
 /** Detect whether the internal date value is NaN. */
 extern JS_FRIEND_API(bool)
 DateIsValid(JSContext* cx, JS::HandleObject obj, bool* isValid);
 
 extern JS_FRIEND_API(bool)
 DateGetMsecSinceEpoch(JSContext* cx, JS::HandleObject obj, double* msecSinceEpoch);
 
rename from js/src/util/PortableMath.h
rename to js/src/jslibmath.h
--- a/js/src/util/PortableMath.h
+++ b/js/src/jslibmath.h
@@ -1,96 +1,57 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef util_PortableMath_h
-#define util_PortableMath_h
+#ifndef jslibmath_h
+#define jslibmath_h
 
 #include "mozilla/FloatingPoint.h"
 
 #include <math.h>
 
-#include "vm/JSContext.h"  // for js::AutoUnsafeCallWithABI
+#include "jsnum.h"
+
+#include "vm/JSContext.h"
 
 /*
  * Use system provided math routines.
  */
 
 /* The right copysign function is not always named the same thing. */
 #ifdef __GNUC__
-    #define js_copysign __builtin_copysign
+#define js_copysign __builtin_copysign
 #elif defined _WIN32
-    #define js_copysign _copysign
+#define js_copysign _copysign
 #else
-    #define js_copysign copysign
+#define js_copysign copysign
 #endif
 
-// This macro is should be `one' if current compiler supports builtin functions
-// like __builtin_sadd_overflow.
-#if __GNUC__ >= 5
-    // GCC 5 and above supports these functions.
-    #define BUILTIN_CHECKED_ARITHMETIC_SUPPORTED(x) 1
-#else
-    // For CLANG, we use its own function to check for this.
-    #ifdef __has_builtin
-        #define BUILTIN_CHECKED_ARITHMETIC_SUPPORTED(x) __has_builtin(x)
-    #endif
+/* Consistency wrapper for platform deviations in fmod() */
+static inline double
+js_fmod(double d, double d2)
+{
+#ifdef XP_WIN
+    /*
+     * Workaround MS fmod bug where 42 % (1/0) => NaN, not 42.
+     * Workaround MS fmod bug where -0 % -N => 0, not -0.
+     */
+    if ((mozilla::IsFinite(d) && mozilla::IsInfinite(d2)) ||
+        (d == 0 && mozilla::IsFinite(d2))) {
+        return d;
+    }
 #endif
-#ifndef BUILTIN_CHECKED_ARITHMETIC_SUPPORTED
-    #define BUILTIN_CHECKED_ARITHMETIC_SUPPORTED(x) 0
-#endif
+    return fmod(d, d2);
+}
 
 namespace js {
 
-MOZ_MUST_USE inline bool
-SafeAdd(int32_t one, int32_t two, int32_t* res)
-{
-#if BUILTIN_CHECKED_ARITHMETIC_SUPPORTED(__builtin_sadd_overflow)
-    // Using compiler's builtin function.
-    return !__builtin_sadd_overflow(one, two, res);
-#else
-    // Use unsigned for the 32-bit operation since signed overflow gets
-    // undefined behavior.
-    *res = uint32_t(one) + uint32_t(two);
-    int64_t ores = (int64_t)one + (int64_t)two;
-    return ores == (int64_t)*res;
-#endif
-}
-
-MOZ_MUST_USE inline bool
-SafeSub(int32_t one, int32_t two, int32_t* res)
-{
-#if BUILTIN_CHECKED_ARITHMETIC_SUPPORTED(__builtin_ssub_overflow)
-    return !__builtin_ssub_overflow(one, two, res);
-#else
-    *res = uint32_t(one) - uint32_t(two);
-    int64_t ores = (int64_t)one - (int64_t)two;
-    return ores == (int64_t)*res;
-#endif
-}
-
-MOZ_MUST_USE inline bool
-SafeMul(int32_t one, int32_t two, int32_t* res)
-{
-#if BUILTIN_CHECKED_ARITHMETIC_SUPPORTED(__builtin_smul_overflow)
-    return !__builtin_smul_overflow(one, two, res);
-#else
-    *res = uint32_t(one) * uint32_t(two);
-    int64_t ores = (int64_t)one * (int64_t)two;
-    return ores == (int64_t)*res;
-#endif
-}
-
-/**
- * ES-compliant floating-point division.
- * <https://tc39.github.io/ecma262/#sec-applying-the-div-operator>
- */
 inline double
 NumberDiv(double a, double b)
 {
     AutoUnsafeCallWithABI unsafe;
     if (b == 0) {
         if (a == 0 || mozilla::IsNaN(a)
 #ifdef XP_WIN
             || mozilla::IsNaN(b) /* XXX MSVC miscompiles such that (NaN == 0) */
@@ -101,37 +62,20 @@ NumberDiv(double a, double b)
         if (mozilla::IsNegative(a) != mozilla::IsNegative(b))
             return mozilla::NegativeInfinity<double>();
         return mozilla::PositiveInfinity<double>();
     }
 
     return a / b;
 }
 
-/**
- * ES-compliant floating-point remainder operation.
- * <https://tc39.github.io/ecma262/#sec-applying-the-mod-operator>
- */
 inline double
 NumberMod(double a, double b)
 {
     AutoUnsafeCallWithABI unsafe;
     if (b == 0)
         return JS::GenericNaN();
-
-#ifdef XP_WIN
-    /*
-     * Workaround MS fmod bug where 42 % (1/0) => NaN, not 42.
-     * Workaround MS fmod bug where -0 % -N => 0, not -0.
-     */
-    if ((mozilla::IsFinite(a) && mozilla::IsInfinite(b)) ||
-        (a == 0 && mozilla::IsFinite(b)))
-    {
-        return a;
-    }
-#endif
-
-    return fmod(a, b);
+    return js_fmod(a, b);
 }
 
 } // namespace js
 
-#endif /* util_PortableMath_h */
+#endif /* jslibmath_h */
rename from js/src/builtin/Math.cpp
rename to js/src/jsmath.cpp
--- a/js/src/builtin/Math.cpp
+++ b/js/src/jsmath.cpp
@@ -3,37 +3,37 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * JS math package.
  */
 
-#include "builtin/Math.h"
+#include "jsmath.h"
 
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Unused.h"
 #include "mozilla/WrappingOperations.h"
 
 #include <algorithm>  // for std::max
 #include <fcntl.h>
 #ifdef XP_UNIX
 # include <unistd.h>
 #endif
 
 #include "fdlibm.h"
 #include "jsapi.h"
+#include "jslibmath.h"
 #include "jstypes.h"
 
 #include "jit/InlinableNatives.h"
 #include "js/Class.h"
-#include "util/PortableMath.h"
 #include "util/Windows.h"
 #include "vm/JSAtom.h"
 #include "vm/JSCompartment.h"
 #include "vm/JSContext.h"
 #include "vm/Time.h"
 
 #include "vm/JSObject-inl.h"
 
rename from js/src/builtin/Math.h
rename to js/src/jsmath.h
--- a/js/src/builtin/Math.h
+++ b/js/src/jsmath.h
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef builtin_Math_h
-#define builtin_Math_h
+#ifndef jsmath_h
+#define jsmath_h
 
 #include "mozilla/MemoryReporting.h"
 
 #include <cmath>
 #include <stdint.h>
 
 #include "NamespaceImports.h"
 
@@ -427,9 +427,9 @@ math_sign_uncached(double x);
 extern double
 math_cbrt_impl(MathCache* cache, double x);
 
 extern double
 math_cbrt_uncached(double x);
 
 } /* namespace js */
 
-#endif /* builtin_Math_h */
+#endif /* jsmath_h */
rename from js/src/builtin/Number.cpp
rename to js/src/jsnum.cpp
--- a/js/src/builtin/Number.cpp
+++ b/js/src/jsnum.cpp
@@ -3,43 +3,43 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * JS number type and wrapper class.
  */
 
-#include "builtin/Number.h"
+#include "jsnum.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/RangedPtr.h"
 
 #ifdef HAVE_LOCALECONV
-# include <locale.h>
+#include <locale.h>
 #endif
 #include <math.h>
 #include <string.h>
 
+#include "jsstr.h"
 #include "jstypes.h"
 
-#include "builtin/String.h"
 #include "double-conversion/double-conversion.h"
 #include "js/Conversions.h"
 #include "util/DoubleToString.h"
-#include "util/StringBuffer.h"
 #include "vm/GlobalObject.h"
 #include "vm/JSAtom.h"
 #include "vm/JSContext.h"
 #include "vm/JSObject.h"
+#include "vm/StringBuffer.h"
 
 #include "vm/NativeObject-inl.h"
 #include "vm/NumberObject-inl.h"
-#include "vm/StringType-inl.h"
+#include "vm/String-inl.h"
 
 using namespace js;
 
 using mozilla::Abs;
 using mozilla::ArrayLength;
 using mozilla::MinNumberValue;
 using mozilla::NegativeInfinity;
 using mozilla::PositiveInfinity;
rename from js/src/builtin/Number.h
rename to js/src/jsnum.h
--- a/js/src/builtin/Number.h
+++ b/js/src/jsnum.h
@@ -1,25 +1,41 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef builtin_Number_h
-#define builtin_Number_h
+#ifndef jsnum_h
+#define jsnum_h
 
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/Range.h"
 
 #include "NamespaceImports.h"
 
 #include "js/Conversions.h"
 
-#include "vm/StringType.h"
+#include "vm/String.h"
+
+
+// This macro is should be `one' if current compiler supports builtin functions
+// like __builtin_sadd_overflow.
+#if __GNUC__ >= 5
+    // GCC 5 and above supports these functions.
+    #define BUILTIN_CHECKED_ARITHMETIC_SUPPORTED(x) 1
+#else
+    // For CLANG, we use its own function to check for this.
+    #ifdef __has_builtin
+        #define BUILTIN_CHECKED_ARITHMETIC_SUPPORTED(x) __has_builtin(x)
+    #endif
+#endif
+#ifndef BUILTIN_CHECKED_ARITHMETIC_SUPPORTED
+    #define BUILTIN_CHECKED_ARITHMETIC_SUPPORTED(x) 0
+#endif
 
 namespace js {
 
 class StringBuffer;
 
 extern MOZ_MUST_USE bool
 InitRuntimeNumberState(JSRuntime* rt);
 
@@ -257,11 +273,50 @@ MOZ_MUST_USE bool
 ToIndex(JSContext* cx, JS::HandleValue v, const unsigned errorNumber, uint64_t* index);
 
 static MOZ_MUST_USE inline bool
 ToIndex(JSContext* cx, JS::HandleValue v, uint64_t* index)
 {
     return ToIndex(cx, v, JSMSG_BAD_INDEX, index);
 }
 
+MOZ_MUST_USE inline bool
+SafeAdd(int32_t one, int32_t two, int32_t* res)
+{
+#if BUILTIN_CHECKED_ARITHMETIC_SUPPORTED(__builtin_sadd_overflow)
+    // Using compiler's builtin function.
+    return !__builtin_sadd_overflow(one, two, res);
+#else
+    // Use unsigned for the 32-bit operation since signed overflow gets
+    // undefined behavior.
+    *res = uint32_t(one) + uint32_t(two);
+    int64_t ores = (int64_t)one + (int64_t)two;
+    return ores == (int64_t)*res;
+#endif
+}
+
+MOZ_MUST_USE inline bool
+SafeSub(int32_t one, int32_t two, int32_t* res)
+{
+#if BUILTIN_CHECKED_ARITHMETIC_SUPPORTED(__builtin_ssub_overflow)
+    return !__builtin_ssub_overflow(one, two, res);
+#else
+    *res = uint32_t(one) - uint32_t(two);
+    int64_t ores = (int64_t)one - (int64_t)two;
+    return ores == (int64_t)*res;
+#endif
+}
+
+MOZ_MUST_USE inline bool
+SafeMul(int32_t one, int32_t two, int32_t* res)
+{
+#if BUILTIN_CHECKED_ARITHMETIC_SUPPORTED(__builtin_smul_overflow)
+    return !__builtin_smul_overflow(one, two, res);
+#else
+    *res = uint32_t(one) * uint32_t(two);
+    int64_t ores = (int64_t)one * (int64_t)two;
+    return ores == (int64_t)*res;
+#endif
+}
+
 } /* namespace js */
 
-#endif /* builtin_Number_h */
+#endif /* jsnum_h */
rename from js/src/builtin/String.cpp
rename to js/src/jsstr.cpp
--- a/js/src/builtin/String.cpp
+++ b/js/src/jsstr.cpp
@@ -1,75 +1,77 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "builtin/String.h"
+#include "jsstr.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/PodOperations.h"
 #include "mozilla/Range.h"
 #include "mozilla/TypeTraits.h"
 #include "mozilla/Unused.h"
 
 #include <ctype.h>
 #include <limits>
 #include <string.h>
 
 #include "jsapi.h"
+#include "jsarray.h"
+#include "jsbool.h"
+#include "jsnum.h"
 #include "jstypes.h"
 #include "jsutil.h"
 
-#include "builtin/Array.h"
-#include "builtin/Boolean.h"
 #include "builtin/intl/CommonFunctions.h"
 #include "builtin/intl/ICUStubs.h"
-#include "builtin/Number.h"
 #include "builtin/RegExp.h"
 #include "jit/InlinableNatives.h"
 #include "js/Conversions.h"
 #include "js/UniquePtr.h"
 #if ENABLE_INTL_API
 # include "unicode/uchar.h"
 # include "unicode/unorm2.h"
 #endif
-#include "util/StringBuffer.h"
-#include "util/Unicode.h"
 #include "vm/BytecodeUtil.h"
 #include "vm/GlobalObject.h"
 #include "vm/Interpreter.h"
 #include "vm/JSAtom.h"
 #include "vm/JSContext.h"
 #include "vm/JSObject.h"
 #include "vm/Opcodes.h"
 #include "vm/Printer.h"
 #include "vm/RegExpObject.h"
 #include "vm/RegExpStatics.h"
 #include "vm/SelfHosting.h"
+#include "vm/StringBuffer.h"
+#include "vm/Unicode.h"
 
 #include "vm/Interpreter-inl.h"
+#include "vm/String-inl.h"
 #include "vm/StringObject-inl.h"
-#include "vm/StringType-inl.h"
 #include "vm/TypeInference-inl.h"
 
 using namespace js;
 using namespace js::gc;
 
 using JS::Symbol;
 using JS::SymbolCode;
 
 using mozilla::CheckedInt;
 using mozilla::IsNaN;
+using mozilla::IsNegativeZero;
 using mozilla::IsSame;
 using mozilla::PodCopy;
+using mozilla::PodEqual;
 using mozilla::RangedPtr;
 
 using JS::AutoCheckCannotGC;
 
 static JSLinearString*
 ArgToLinearString(JSContext* cx, const CallArgs& args, unsigned argno)
 {
     if (argno >= args.length())
@@ -2409,16 +2411,39 @@ js::str_lastIndexOf(JSContext* cx, unsig
         else
             res = LastIndexOfImpl(textChars, len, searchStr->twoByteChars(nogc), searchLen, start);
     }
 
     args.rval().setInt32(res);
     return true;
 }
 
+bool
+js::HasSubstringAt(JSLinearString* text, JSLinearString* pat, size_t start)
+{
+    MOZ_ASSERT(start + pat->length() <= text->length());
+
+    size_t patLen = pat->length();
+
+    AutoCheckCannotGC nogc;
+    if (text->hasLatin1Chars()) {
+        const Latin1Char* textChars = text->latin1Chars(nogc) + start;
+        if (pat->hasLatin1Chars())
+            return PodEqual(textChars, pat->latin1Chars(nogc), patLen);
+
+        return EqualChars(textChars, pat->twoByteChars(nogc), patLen);
+    }
+
+    const char16_t* textChars = text->twoByteChars(nogc) + start;
+    if (pat->hasTwoByteChars())
+        return PodEqual(textChars, pat->twoByteChars(nogc), patLen);
+
+    return EqualChars(pat->latin1Chars(nogc), textChars, patLen);
+}
+
 // ES2018 draft rev de77aaeffce115deaf948ed30c7dbe4c60983c0c
 // 21.1.3.20 String.prototype.startsWith ( searchString [ , position ] )
 bool
 js::str_startsWith(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 
     // Steps 1-2.
@@ -3677,16 +3702,429 @@ js::InitStringClass(JSContext* cx, Handl
         return nullptr;
 
     if (!GlobalObject::initBuiltinConstructor(cx, global, JSProto_String, ctor, proto))
         return nullptr;
 
     return proto;
 }
 
+const char*
+js::ValueToPrintable(JSContext* cx, const Value& vArg, JSAutoByteString* bytes, bool asSource)
+{
+    RootedValue v(cx, vArg);
+    JSString* str;
+    if (asSource)
+        str = ValueToSource(cx, v);
+    else
+        str = ToString<CanGC>(cx, v);
+    if (!str)
+        return nullptr;
+    str = QuoteString(cx, str, 0);
+    if (!str)
+        return nullptr;
+    return bytes->encodeLatin1(cx, str);
+}
+
+template <AllowGC allowGC>
+JSString*
+js::ToStringSlow(JSContext* cx, typename MaybeRooted<Value, allowGC>::HandleType arg)
+{
+    /* As with ToObjectSlow, callers must verify that |arg| isn't a string. */
+    MOZ_ASSERT(!arg.isString());
+
+    Value v = arg;
+    if (!v.isPrimitive()) {
+        MOZ_ASSERT(!cx->helperThread());
+        if (!allowGC)
+            return nullptr;
+        RootedValue v2(cx, v);
+        if (!ToPrimitive(cx, JSTYPE_STRING, &v2))
+            return nullptr;
+        v = v2;
+    }
+
+    JSString* str;
+    if (v.isString()) {
+        str = v.toString();
+    } else if (v.isInt32()) {
+        str = Int32ToString<allowGC>(cx, v.toInt32());
+    } else if (v.isDouble()) {
+        str = NumberToString<allowGC>(cx, v.toDouble());
+    } else if (v.isBoolean()) {
+        str = BooleanToString(cx, v.toBoolean());
+    } else if (v.isNull()) {
+        str = cx->names().null;
+    } else if (v.isSymbol()) {
+        MOZ_ASSERT(!cx->helperThread());
+        if (allowGC) {
+            JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
+                                      JSMSG_SYMBOL_TO_STRING);
+        }
+        return nullptr;
+    } else {
+        MOZ_ASSERT(v.isUndefined());
+        str = cx->names().undefined;
+    }
+    return str;
+}
+
+template JSString*
+js::ToStringSlow<CanGC>(JSContext* cx, HandleValue arg);
+
+template JSString*
+js::ToStringSlow<NoGC>(JSContext* cx, const Value& arg);
+
+JS_PUBLIC_API(JSString*)
+js::ToStringSlow(JSContext* cx, HandleValue v)
+{
+    return ToStringSlow<CanGC>(cx, v);
+}
+
+static JSString*
+SymbolToSource(JSContext* cx, Symbol* symbol)
+{
+    RootedString desc(cx, symbol->description());
+    SymbolCode code = symbol->code();
+    if (code != SymbolCode::InSymbolRegistry && code != SymbolCode::UniqueSymbol) {
+        // Well-known symbol.
+        MOZ_ASSERT(uint32_t(code) < JS::WellKnownSymbolLimit);
+        return desc;
+    }
+
+    StringBuffer buf(cx);
+    if (code == SymbolCode::InSymbolRegistry ? !buf.append("Symbol.for(") : !buf.append("Symbol("))
+        return nullptr;
+    if (desc) {
+        desc = StringToSource(cx, desc);
+        if (!desc || !buf.append(desc))
+            return nullptr;
+    }
+    if (!buf.append(')'))
+        return nullptr;
+    return buf.finishString();
+}
+
+JSString*
+js::ValueToSource(JSContext* cx, HandleValue v)
+{
+    if (!CheckRecursionLimit(cx))
+        return nullptr;
+    assertSameCompartment(cx, v);
+
+    if (v.isUndefined())
+        return cx->names().void0;
+    if (v.isString())
+        return StringToSource(cx, v.toString());
+    if (v.isSymbol())
+        return SymbolToSource(cx, v.toSymbol());
+    if (v.isPrimitive()) {
+        /* Special case to preserve negative zero, _contra_ toString. */
+        if (v.isDouble() && IsNegativeZero(v.toDouble())) {
+            static const Latin1Char negativeZero[] = {'-', '0'};
+
+            return NewStringCopyN<CanGC>(cx, negativeZero, mozilla::ArrayLength(negativeZero));
+        }
+        return ToString<CanGC>(cx, v);
+    }
+
+    RootedValue fval(cx);
+    RootedObject obj(cx, &v.toObject());
+    if (!GetProperty(cx, obj, obj, cx->names().toSource, &fval))
+        return nullptr;
+    if (IsCallable(fval)) {
+        RootedValue v(cx);
+        if (!js::Call(cx, fval, obj, &v))
+            return nullptr;
+
+        return ToString<CanGC>(cx, v);
+    }
+
+    return ObjectToSource(cx, obj);
+}
+
+JSString*
+js::StringToSource(JSContext* cx, JSString* str)
+{
+    return QuoteString(cx, str, '"');
+}
+
+bool
+js::EqualChars(JSLinearString* str1, JSLinearString* str2)
+{
+    MOZ_ASSERT(str1->length() == str2->length());
+
+    size_t len = str1->length();
+
+    AutoCheckCannotGC nogc;
+    if (str1->hasTwoByteChars()) {
+        if (str2->hasTwoByteChars())
+            return PodEqual(str1->twoByteChars(nogc), str2->twoByteChars(nogc), len);
+
+        return EqualChars(str2->latin1Chars(nogc), str1->twoByteChars(nogc), len);
+    }
+
+    if (str2->hasLatin1Chars())
+        return PodEqual(str1->latin1Chars(nogc), str2->latin1Chars(nogc), len);
+
+    return EqualChars(str1->latin1Chars(nogc), str2->twoByteChars(nogc), len);
+}
+
+bool
+js::EqualStrings(JSContext* cx, JSString* str1, JSString* str2, bool* result)
+{
+    if (str1 == str2) {
+        *result = true;
+        return true;
+    }
+
+    size_t length1 = str1->length();
+    if (length1 != str2->length()) {
+        *result = false;
+        return true;
+    }
+
+    JSLinearString* linear1 = str1->ensureLinear(cx);
+    if (!linear1)
+        return false;
+    JSLinearString* linear2 = str2->ensureLinear(cx);
+    if (!linear2)
+        return false;
+
+    *result = EqualChars(linear1, linear2);
+    return true;
+}
+
+bool
+js::EqualStrings(JSLinearString* str1, JSLinearString* str2)
+{
+    if (str1 == str2)
+        return true;
+
+    size_t length1 = str1->length();
+    if (length1 != str2->length())
+        return false;
+
+    return EqualChars(str1, str2);
+}
+
+static int32_t
+CompareStringsImpl(JSLinearString* str1, JSLinearString* str2)
+{
+    size_t len1 = str1->length();
+    size_t len2 = str2->length();
+
+    AutoCheckCannotGC nogc;
+    if (str1->hasLatin1Chars()) {
+        const Latin1Char* chars1 = str1->latin1Chars(nogc);
+        return str2->hasLatin1Chars()
+               ? CompareChars(chars1, len1, str2->latin1Chars(nogc), len2)
+               : CompareChars(chars1, len1, str2->twoByteChars(nogc), len2);
+    }
+
+    const char16_t* chars1 = str1->twoByteChars(nogc);
+    return str2->hasLatin1Chars()
+           ? CompareChars(chars1, len1, str2->latin1Chars(nogc), len2)
+           : CompareChars(chars1, len1, str2->twoByteChars(nogc), len2);
+}
+
+int32_t
+js::CompareChars(const char16_t* s1, size_t len1, JSLinearString* s2)
+{
+    AutoCheckCannotGC nogc;
+    return s2->hasLatin1Chars()
+           ? CompareChars(s1, len1, s2->latin1Chars(nogc), s2->length())
+           : CompareChars(s1, len1, s2->twoByteChars(nogc), s2->length());
+}
+
+bool
+js::CompareStrings(JSContext* cx, JSString* str1, JSString* str2, int32_t* result)
+{
+    MOZ_ASSERT(str1);
+    MOZ_ASSERT(str2);
+
+    if (str1 == str2) {
+        *result = 0;
+        return true;
+    }
+
+    JSLinearString* linear1 = str1->ensureLinear(cx);
+    if (!linear1)
+        return false;
+
+    JSLinearString* linear2 = str2->ensureLinear(cx);
+    if (!linear2)
+        return false;
+
+    *result = CompareStringsImpl(linear1, linear2);
+    return true;
+}
+
+int32_t
+js::CompareAtoms(JSAtom* atom1, JSAtom* atom2)
+{
+    return CompareStringsImpl(atom1, atom2);
+}
+
+bool
+js::StringEqualsAscii(JSLinearString* str, const char* asciiBytes)
+{
+    size_t length = strlen(asciiBytes);
+#ifdef DEBUG
+    for (size_t i = 0; i != length; ++i)
+        MOZ_ASSERT(unsigned(asciiBytes[i]) <= 127);
+#endif
+    if (length != str->length())
+        return false;
+
+    const Latin1Char* latin1 = reinterpret_cast<const Latin1Char*>(asciiBytes);
+
+    AutoCheckCannotGC nogc;
+    return str->hasLatin1Chars()
+           ? PodEqual(latin1, str->latin1Chars(nogc), length)
+           : EqualChars(latin1, str->twoByteChars(nogc), length);
+}
+
+int32_t
+js_fputs(const char16_t* s, FILE* f)
+{
+    while (*s != 0) {
+        if (fputwc(wchar_t(*s), f) == WEOF)
+            return WEOF;
+        s++;
+    }
+    return 1;
+}
+
+UniqueChars
+js::DuplicateString(JSContext* cx, const char* s)
+{
+    size_t n = strlen(s) + 1;
+    auto ret = cx->make_pod_array<char>(n);
+    if (!ret)
+        return ret;
+    PodCopy(ret.get(), s, n);
+    return ret;
+}
+
+UniqueTwoByteChars
+js::DuplicateString(JSContext* cx, const char16_t* s)
+{
+    size_t n = js_strlen(s) + 1;
+    auto ret = cx->make_pod_array<char16_t>(n);
+    if (!ret)
+        return ret;
+    PodCopy(ret.get(), s, n);
+    return ret;
+}
+
+UniqueChars
+js::DuplicateString(const char* s)
+{
+    size_t n = strlen(s) + 1;
+    UniqueChars ret(js_pod_malloc<char>(n));
+    if (!ret)
+        return ret;
+    PodCopy(ret.get(), s, n);
+    return ret;
+}
+
+UniqueChars
+js::DuplicateString(const char* s, size_t n)
+{
+    UniqueChars ret(js_pod_malloc<char>(n + 1));
+    if (!ret)
+        return nullptr;
+    PodCopy(ret.get(), s, n);
+    ret[n] = 0;
+    return ret;
+}
+
+UniqueTwoByteChars
+js::DuplicateString(const char16_t* s)
+{
+    return DuplicateString(s, js_strlen(s));
+}
+
+UniqueTwoByteChars
+js::DuplicateString(const char16_t* s, size_t n)
+{
+    UniqueTwoByteChars ret(js_pod_malloc<char16_t>(n + 1));
+    if (!ret)
+        return nullptr;
+    PodCopy(ret.get(), s, n);
+    ret[n] = 0;
+    return ret;
+}
+
+JS_PUBLIC_API(char*)
+js_strdup(const char* s)
+{
+    return DuplicateString(s).release();
+}
+
+template <typename CharT>
+const CharT*
+js_strchr_limit(const CharT* s, char16_t c, const CharT* limit)
+{
+    while (s < limit) {
+        if (*s == c)
+            return s;
+        s++;
+    }
+    return nullptr;
+}
+
+template const Latin1Char*
+js_strchr_limit(const Latin1Char* s, char16_t c, const Latin1Char* limit);
+
+template const char16_t*
+js_strchr_limit(const char16_t* s, char16_t c, const char16_t* limit);
+
+char16_t*
+js::InflateString(JSContext* cx, const char* bytes, size_t length)
+{
+    char16_t* chars = cx->pod_malloc<char16_t>(length + 1);
+    if (!chars)
+        return nullptr;
+    CopyAndInflateChars(chars, bytes, length);
+    chars[length] = 0;
+    return chars;
+}
+
+template <typename CharT>
+bool
+js::DeflateStringToBuffer(JSContext* maybecx, const CharT* src, size_t srclen,
+                          char* dst, size_t* dstlenp)
+{
+    size_t dstlen = *dstlenp;
+    if (srclen > dstlen) {
+        for (size_t i = 0; i < dstlen; i++)
+            dst[i] = char(src[i]);
+        if (maybecx) {
+            AutoSuppressGC suppress(maybecx);
+            JS_ReportErrorNumberASCII(maybecx, GetErrorMessage, nullptr,
+                                      JSMSG_BUFFER_TOO_SMALL);
+        }
+        return false;
+    }
+    for (size_t i = 0; i < srclen; i++)
+        dst[i] = char(src[i]);
+    *dstlenp = srclen;
+    return true;
+}
+
+template bool
+js::DeflateStringToBuffer(JSContext* maybecx, const Latin1Char* src, size_t srclen,
+                          char* dst, size_t* dstlenp);
+
+template bool
+js::DeflateStringToBuffer(JSContext* maybecx, const char16_t* src, size_t srclen,
+                          char* dst, size_t* dstlenp);
+
 #define ____ false
 
 /*
  * Uri reserved chars + #:
  * - 35: #
  * - 36: $
  * - 38: &
  * - 43: +
@@ -4032,16 +4470,192 @@ js::EncodeURI(JSContext* cx, StringBuffe
         return false;
     if (result == EncodeResult::Encode_BadUri) {
         JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_BAD_URI);
         return false;
     }
     return true;
 }
 
+/*
+ * Convert one UCS-4 char and write it into a UTF-8 buffer, which must be at
+ * least 4 bytes long.  Return the number of UTF-8 bytes of data written.
+ */
+uint32_t
+js::OneUcs4ToUtf8Char(uint8_t* utf8Buffer, uint32_t ucs4Char)
+{
+    MOZ_ASSERT(ucs4Char <= unicode::NonBMPMax);
+
+    if (ucs4Char < 0x80) {
+        utf8Buffer[0] = uint8_t(ucs4Char);
+        return 1;
+    }
+
+    uint32_t a = ucs4Char >> 11;
+    uint32_t utf8Length = 2;
+    while (a) {
+        a >>= 5;
+        utf8Length++;
+    }
+
+    MOZ_ASSERT(utf8Length <= 4);
+
+    uint32_t i = utf8Length;
+    while (--i) {
+        utf8Buffer[i] = uint8_t((ucs4Char & 0x3F) | 0x80);
+        ucs4Char >>= 6;
+    }
+
+    utf8Buffer[0] = uint8_t(0x100 - (1 << (8 - utf8Length)) + ucs4Char);
+    return utf8Length;
+}
+
+size_t
+js::PutEscapedStringImpl(char* buffer, size_t bufferSize, GenericPrinter* out, JSLinearString* str,
+                         uint32_t quote)
+{
+    size_t len = str->length();
+    AutoCheckCannotGC nogc;
+    return str->hasLatin1Chars()
+           ? PutEscapedStringImpl(buffer, bufferSize, out, str->latin1Chars(nogc), len, quote)
+           : PutEscapedStringImpl(buffer, bufferSize, out, str->twoByteChars(nogc), len, quote);
+}
+
+template <typename CharT>
+size_t
+js::PutEscapedStringImpl(char* buffer, size_t bufferSize, GenericPrinter* out, const CharT* chars,
+                         size_t length, uint32_t quote)
+{
+    enum {
+        STOP, FIRST_QUOTE, LAST_QUOTE, CHARS, ESCAPE_START, ESCAPE_MORE
+    } state;
+
+    MOZ_ASSERT(quote == 0 || quote == '\'' || quote == '"');
+    MOZ_ASSERT_IF(!buffer, bufferSize == 0);
+    MOZ_ASSERT_IF(out, !buffer);
+
+    if (bufferSize == 0)
+        buffer = nullptr;
+    else
+        bufferSize--;
+
+    const CharT* charsEnd = chars + length;
+    size_t n = 0;
+    state = FIRST_QUOTE;
+    unsigned shift = 0;
+    unsigned hex = 0;
+    unsigned u = 0;
+    char c = 0;  /* to quell GCC warnings */
+
+    for (;;) {
+        switch (state) {
+          case STOP:
+            goto stop;
+          case FIRST_QUOTE:
+            state = CHARS;
+            goto do_quote;
+          case LAST_QUOTE:
+            state = STOP;
+          do_quote:
+            if (quote == 0)
+                continue;
+            c = (char)quote;
+            break;
+          case CHARS:
+            if (chars == charsEnd) {
+                state = LAST_QUOTE;
+                continue;
+            }
+            u = *chars++;
+            if (u < ' ') {
+                if (u != 0) {
+                    const char* escape = strchr(js_EscapeMap, (int)u);
+                    if (escape) {
+                        u = escape[1];
+                        goto do_escape;
+                    }
+                }
+                goto do_hex_escape;
+            }
+            if (u < 127) {
+                if (u == quote || u == '\\')
+                    goto do_escape;
+                c = (char)u;
+            } else if (u < 0x100) {
+                goto do_hex_escape;
+            } else {
+                shift = 16;
+                hex = u;
+                u = 'u';
+                goto do_escape;
+            }
+            break;
+          do_hex_escape:
+            shift = 8;
+            hex = u;
+            u = 'x';
+          do_escape:
+            c = '\\';
+            state = ESCAPE_START;
+            break;
+          case ESCAPE_START:
+            MOZ_ASSERT(' ' <= u && u < 127);
+            c = (char)u;
+            state = ESCAPE_MORE;
+            break;
+          case ESCAPE_MORE:
+            if (shift == 0) {
+                state = CHARS;
+                continue;
+            }
+            shift -= 4;
+            u = 0xF & (hex >> shift);
+            c = (char)(u + (u < 10 ? '0' : 'A' - 10));
+            break;
+        }
+        if (buffer) {
+            MOZ_ASSERT(n <= bufferSize);
+            if (n != bufferSize) {
+                buffer[n] = c;
+            } else {
+                buffer[n] = '\0';
+                buffer = nullptr;
+            }
+        } else if (out) {
+            if (!out->put(&c, 1))
+                return size_t(-1);
+        }
+        n++;
+    }
+  stop:
+    if (buffer)
+        buffer[n] = '\0';
+    return n;
+}
+
+template size_t
+js::PutEscapedStringImpl(char* buffer, size_t bufferSize, GenericPrinter* out, const Latin1Char* chars,
+                         size_t length, uint32_t quote);
+
+template size_t
+js::PutEscapedStringImpl(char* buffer, size_t bufferSize, GenericPrinter* out, const char* chars,
+                         size_t length, uint32_t quote);
+
+template size_t
+js::PutEscapedStringImpl(char* buffer, size_t bufferSize, GenericPrinter* out, const char16_t* chars,
+                         size_t length, uint32_t quote);
+
+template size_t
+js::PutEscapedString(char* buffer, size_t bufferSize, const Latin1Char* chars, size_t length,
+                     uint32_t quote);
+
+template size_t
+js::PutEscapedString(char* buffer, size_t bufferSize, const char16_t* chars, size_t length,
+                     uint32_t quote);
+
 static bool
 FlatStringMatchHelper(JSContext* cx, HandleString str, HandleString pattern, bool* isFlat, int32_t* match)
 {
     RootedLinearString linearPattern(cx, pattern->ensureLinear(cx));
     if (!linearPattern)
         return false;
 
     static const size_t MAX_FLAT_PAT_LEN = 256;
rename from js/src/builtin/String.h
rename to js/src/jsstr.h
--- a/js/src/builtin/String.h
+++ b/js/src/jsstr.h
@@ -1,38 +1,295 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef builtin_String_h
-#define builtin_String_h
+#ifndef jsstr_h
+#define jsstr_h
 
 #include "mozilla/HashFunctions.h"
 #include "mozilla/PodOperations.h"
 
 #include <stdio.h>
 #include <string.h>
 
 #include "jsutil.h"
 #include "NamespaceImports.h"
 
 #include "gc/Rooting.h"
 #include "js/RootingAPI.h"
 #include "js/UniquePtr.h"
-#include "util/Unicode.h"
 #include "vm/Printer.h"
+#include "vm/Unicode.h"
+
+class JSAutoByteString;
+class JSLinearString;
+
+namespace js {
+
+class StringBuffer;
+
+template <AllowGC allowGC>
+extern JSString*
+ConcatStrings(JSContext* cx,
+              typename MaybeRooted<JSString*, allowGC>::HandleType left,
+              typename MaybeRooted<JSString*, allowGC>::HandleType right);
+
+// Return s advanced past any Unicode white space characters.
+template <typename CharT>
+static inline const CharT*
+SkipSpace(const CharT* s, const CharT* end)
+{
+    MOZ_ASSERT(s <= end);
+
+    while (s < end && unicode::IsSpace(*s))
+        s++;
+
+    return s;
+}
+
+// Return less than, equal to, or greater than zero depending on whether
+// s1 is less than, equal to, or greater than s2.
+template <typename Char1, typename Char2>
+inline int32_t
+CompareChars(const Char1* s1, size_t len1, const Char2* s2, size_t len2)
+{
+    size_t n = Min(len1, len2);
+    for (size_t i = 0; i < n; i++) {
+        if (int32_t cmp = s1[i] - s2[i])
+            return cmp;
+    }
+
+    return int32_t(len1 - len2);
+}
+
+extern int32_t
+CompareChars(const char16_t* s1, size_t len1, JSLinearString* s2);
+
+}  /* namespace js */
+
+/*
+ * Shorthands for ASCII (7-bit) decimal and hex conversion.
+ * Manually inline isdigit and isxdigit for performance; MSVC doesn't do this for us.
+ */
+#define JS7_ISDEC(c)    ((((unsigned)(c)) - '0') <= 9)
+#define JS7_ISA2F(c)    ((((((unsigned)(c)) - 'a') <= 5) || (((unsigned)(c)) - 'A') <= 5))
+#define JS7_UNDEC(c)    ((c) - '0')
+#define JS7_ISOCT(c)    ((((unsigned)(c)) - '0') <= 7)
+#define JS7_UNOCT(c)    (JS7_UNDEC(c))
+#define JS7_ISHEX(c)    ((c) < 128 && (JS7_ISDEC(c) || JS7_ISA2F(c)))
+#define JS7_UNHEX(c)    (unsigned)(JS7_ISDEC(c) ? (c) - '0' : 10 + tolower(c) - 'a')
+#define JS7_ISLET(c)    ((c) < 128 && isalpha(c))
+
+static MOZ_ALWAYS_INLINE size_t
+js_strlen(const char16_t* s)
+{
+    return std::char_traits<char16_t>::length(s);
+}
+
+template <typename CharT>
+extern const CharT*
+js_strchr_limit(const CharT* s, char16_t c, const CharT* limit);
+
+extern int32_t
+js_fputs(const char16_t* s, FILE* f);
 
 namespace js {
 
 /* Initialize the String class, returning its prototype object. */
 extern JSObject*
 InitStringClass(JSContext* cx, HandleObject obj);
 
+/*
+ * Convert a value to a printable C string.
+ */
+extern const char*
+ValueToPrintable(JSContext* cx, const Value&, JSAutoByteString* bytes, bool asSource = false);
+
+extern UniqueChars
+DuplicateString(JSContext* cx, const char* s);
+
+extern UniqueTwoByteChars
+DuplicateString(JSContext* cx, const char16_t* s);
+
+/*
+ * These variants do not report OOMs, you must arrange for OOMs to be reported
+ * yourself.
+ */
+extern UniqueChars
+DuplicateString(const char* s);
+
+extern UniqueChars
+DuplicateString(const char* s, size_t n);
+
+extern UniqueTwoByteChars
+DuplicateString(const char16_t* s);
+
+extern UniqueTwoByteChars
+DuplicateString(const char16_t* s, size_t n);
+
+/*
+ * Convert a non-string value to a string, returning null after reporting an
+ * error, otherwise returning a new string reference.
+ */
+template <AllowGC allowGC>
+extern JSString*
+ToStringSlow(JSContext* cx, typename MaybeRooted<Value, allowGC>::HandleType arg);
+
+/*
+ * Convert the given value to a string.  This method includes an inline
+ * fast-path for the case where the value is already a string; if the value is
+ * known not to be a string, use ToStringSlow instead.
+ */
+template <AllowGC allowGC>
+static MOZ_ALWAYS_INLINE JSString*
+ToString(JSContext* cx, JS::HandleValue v)
+{
+    if (v.isString())
+        return v.toString();
+    return ToStringSlow<allowGC>(cx, v);
+}
+
+/*
+ * This function implements E-262-3 section 9.8, toString. Convert the given
+ * value to a string of characters appended to the given buffer. On error, the
+ * passed buffer may have partial results appended.
+ */
+inline bool
+ValueToStringBuffer(JSContext* cx, const Value& v, StringBuffer& sb);
+
+/*
+ * Convert a value to its source expression, returning null after reporting
+ * an error, otherwise returning a new string reference.
+ */
+extern JSString*
+ValueToSource(JSContext* cx, HandleValue v);
+
+/*
+ * Convert a JSString to its source expression; returns null after reporting an
+ * error, otherwise returns a new string reference. No Handle needed since the
+ * input is dead after the GC.
+ */
+extern JSString*
+StringToSource(JSContext* cx, JSString* str);
+
+/*
+ * Test if strings are equal. The caller can call the function even if str1
+ * or str2 are not GC-allocated things.
+ */
+extern bool
+EqualStrings(JSContext* cx, JSString* str1, JSString* str2, bool* result);
+
+/* Use the infallible method instead! */
+extern bool
+EqualStrings(JSContext* cx, JSLinearString* str1, JSLinearString* str2, bool* result) = delete;
+
+/* EqualStrings is infallible on linear strings. */
+extern bool
+EqualStrings(JSLinearString* str1, JSLinearString* str2);
+
+extern bool
+EqualChars(JSLinearString* str1, JSLinearString* str2);
+
+/*
+ * Return less than, equal to, or greater than zero depending on whether
+ * str1 is less than, equal to, or greater than str2.
+ */
+extern bool
+CompareStrings(JSContext* cx, JSString* str1, JSString* str2, int32_t* result);
+
+/*
+ * Same as CompareStrings but for atoms.  Don't use this to just test
+ * for equality; use this when you need an ordering on atoms.
+ */
+extern int32_t
+CompareAtoms(JSAtom* atom1, JSAtom* atom2);
+
+/*
+ * Return true if the string matches the given sequence of ASCII bytes.
+ */
+extern bool
+StringEqualsAscii(JSLinearString* str, const char* asciiBytes);
+
+extern int
+StringFindPattern(JSLinearString* text, JSLinearString* pat, size_t start);
+
+/* Return true if the string contains a pattern at |start|. */
+extern bool
+HasSubstringAt(JSLinearString* text, JSLinearString* pat, size_t start);
+
+template <typename Char1, typename Char2>
+inline bool
+EqualChars(const Char1* s1, const Char2* s2, size_t len);
+
+template <typename Char1>
+inline bool
+EqualChars(const Char1* s1, const Char1* s2, size_t len)
+{
+    return mozilla::PodEqual(s1, s2, len);
+}
+
+template <typename Char1, typename Char2>
+inline bool
+EqualChars(const Char1* s1, const Char2* s2, size_t len)
+{
+    for (const Char1* s1end = s1 + len; s1 < s1end; s1++, s2++) {
+        if (*s1 != *s2)
+            return false;
+    }
+    return true;
+}
+
+/*
+ * Computes |str|'s substring for the range [beginInt, beginInt + lengthInt).
+ * Negative, overlarge, swapped, etc. |beginInt| and |lengthInt| are forbidden
+ * and constitute API misuse.
+ */
+JSString*
+SubstringKernel(JSContext* cx, HandleString str, int32_t beginInt, int32_t lengthInt);
+
+/*
+ * Inflate bytes in ASCII encoding to char16_t code units. Return null on error,
+ * otherwise return the char16_t buffer that was malloc'ed. A null char is
+ * appended.
+ */
+extern char16_t*
+InflateString(JSContext* cx, const char* bytes, size_t length);
+
+/*
+ * Inflate bytes to JS chars in an existing buffer. 'dst' must be large
+ * enough for 'srclen' char16_t code units. The buffer is NOT null-terminated.
+ */
+inline void
+CopyAndInflateChars(char16_t* dst, const char* src, size_t srclen)
+{
+    for (size_t i = 0; i < srclen; i++)
+        dst[i] = (unsigned char) src[i];
+}
+
+inline void
+CopyAndInflateChars(char16_t* dst, const JS::Latin1Char* src, size_t srclen)
+{
+    for (size_t i = 0; i < srclen; i++)
+        dst[i] = src[i];
+}
+
+/*
+ * Deflate JS chars to bytes into a buffer. 'bytes' must be large enough for
+ * 'length chars. The buffer is NOT null-terminated. The destination length
+ * must to be initialized with the buffer size and will contain on return the
+ * number of copied bytes.
+ */
+template <typename CharT>
+extern bool
+DeflateStringToBuffer(JSContext* maybecx, const CharT* chars,
+                      size_t charsLength, char* bytes, size_t* length);
+
 extern bool
 str_fromCharCode(JSContext* cx, unsigned argc, Value* vp);
 
 extern bool
 str_fromCharCode_one_arg(JSContext* cx, HandleValue code, MutableHandleValue rval);
 
 extern bool
 str_fromCodePoint(JSContext* cx, unsigned argc, Value* vp);
@@ -152,16 +409,100 @@ str_normalize(JSContext* cx, unsigned ar
 extern bool
 str_localeCompare(JSContext* cx, unsigned argc, Value* vp);
 
 #endif // EXPOSE_INTL_API
 
 extern bool
 str_concat(JSContext* cx, unsigned argc, Value* vp);
 
+/*
+ * Convert one UCS-4 char and write it into a UTF-8 buffer, which must be at
+ * least 4 bytes long.  Return the number of UTF-8 bytes of data written.
+ */
+extern uint32_t
+OneUcs4ToUtf8Char(uint8_t* utf8Buffer, uint32_t ucs4Char);
+
+extern size_t
+PutEscapedStringImpl(char* buffer, size_t size, GenericPrinter* out, JSLinearString* str,
+                     uint32_t quote);
+
+template <typename CharT>
+extern size_t
+PutEscapedStringImpl(char* buffer, size_t bufferSize, GenericPrinter* out, const CharT* chars,
+                     size_t length, uint32_t quote);
+
+/*
+ * Write str into buffer escaping any non-printable or non-ASCII character
+ * using \escapes for JS string literals.
+ * Guarantees that a NUL is at the end of the buffer unless size is 0. Returns
+ * the length of the written output, NOT including the NUL. Thus, a return
+ * value of size or more means that the output was truncated. If buffer
+ * is null, just returns the length of the output. If quote is not 0, it must
+ * be a single or double quote character that will quote the output.
+*/
+inline size_t
+PutEscapedString(char* buffer, size_t size, JSLinearString* str, uint32_t quote)
+{
+    size_t n = PutEscapedStringImpl(buffer, size, nullptr, str, quote);
+
+    /* PutEscapedStringImpl can only fail with a file. */
+    MOZ_ASSERT(n != size_t(-1));
+    return n;
+}
+
+template <typename CharT>
+inline size_t
+PutEscapedString(char* buffer, size_t bufferSize, const CharT* chars, size_t length, uint32_t quote)
+{
+    size_t n = PutEscapedStringImpl(buffer, bufferSize, nullptr, chars, length, quote);
+
+    /* PutEscapedStringImpl can only fail with a file. */
+    MOZ_ASSERT(n != size_t(-1));
+    return n;
+}
+
+inline bool
+EscapedStringPrinter(GenericPrinter& out, JSLinearString* str, uint32_t quote)
+{
+    return PutEscapedStringImpl(nullptr, 0, &out, str, quote) != size_t(-1);
+}
+
+inline bool
+EscapedStringPrinter(GenericPrinter& out, const char* chars, size_t length, uint32_t quote)
+{
+    return PutEscapedStringImpl(nullptr, 0, &out, chars, length, quote) != size_t(-1);
+}
+
+/*
+ * Write str into file escaping any non-printable or non-ASCII character.
+ * If quote is not 0, it must be a single or double quote character that
+ * will quote the output.
+*/
+inline bool
+FileEscapedString(FILE* fp, JSLinearString* str, uint32_t quote)
+{
+    Fprinter out(fp);
+    bool res = EscapedStringPrinter(out, str, quote);
+    out.finish();
+    return res;
+}
+
+inline bool
+FileEscapedString(FILE* fp, const char* chars, size_t length, uint32_t quote)
+{
+    Fprinter out(fp);
+    bool res = EscapedStringPrinter(out, chars, length, quote);
+    out.finish();
+    return res;
+}
+
+bool
+EncodeURI(JSContext* cx, StringBuffer& sb, const char* chars, size_t length);
+
 ArrayObject*
 str_split_string(JSContext* cx, HandleObjectGroup group, HandleString str, HandleString sep,
                  uint32_t limit);
 
 JSString *
 str_flat_replace_string(JSContext *cx, HandleString string, HandleString pattern,
                         HandleString replacement);
 
@@ -181,9 +522,9 @@ StringConstructor(JSContext* cx, unsigne
 extern bool
 FlatStringMatch(JSContext* cx, unsigned argc, Value* vp);
 
 extern bool
 FlatStringSearch(JSContext* cx, unsigned argc, Value* vp);
 
 } /* namespace js */
 
-#endif /* builtin_String_h */
+#endif /* jsstr_h */
--- a/js/src/moz.build
+++ b/js/src/moz.build
@@ -27,16 +27,20 @@ with Files('gc/**'):
 with Files('jit/**'):
     BUG_COMPONENT = component_jit
 
 # File-specific metadata
 for gcfile in ['devtools/rootAnalysis', 'devtools/gc-ubench', 'devtools/gctrace']:
     with Files(gcfile):
         BUG_COMPONENT = component_gc
 
+for stlfile in ['jsarray.*', 'jsbool*', 'jsdate.*', 'jsnum.*', 'jsstr.*']:
+    with Files(stlfile):
+        BUG_COMPONENT = component_stl
+
 with Files('builtin/intl/*'):
     BUG_COMPONENT = component_intl
 
 
 if CONFIG['JS_BUNDLED_EDITLINE']:
     DIRS += ['editline']
 
 if not CONFIG['JS_DISABLE_SHELL']:
@@ -138,46 +142,42 @@ EXPORTS.js += [
     '../public/Utility.h',
     '../public/Value.h',
     '../public/Vector.h',
     '../public/WeakMapPtr.h',
     '../public/Wrapper.h',
 ]
 
 UNIFIED_SOURCES += [
-    'builtin/Atomics.cpp',
-    'builtin/Boolean.cpp',
-    'builtin/DataView.cpp',
-    'builtin/Date.cpp',
+    'builtin/AtomicsObject.cpp',
+    'builtin/DataViewObject.cpp',
     'builtin/Eval.cpp',
     'builtin/intl/Collator.cpp',
     'builtin/intl/CommonFunctions.cpp',
     'builtin/intl/DateTimeFormat.cpp',
-    'builtin/intl/Intl.cpp',
+    'builtin/intl/IntlObject.cpp',
     'builtin/intl/NumberFormat.cpp',
     'builtin/intl/PluralRules.cpp',
     'builtin/intl/RelativeTimeFormat.cpp',
     'builtin/intl/SharedIntlData.cpp',
     'builtin/JSON.cpp',
-    'builtin/Map.cpp',
+    'builtin/MapObject.cpp',
     'builtin/ModuleObject.cpp',
-    'builtin/Number.cpp',
     'builtin/Object.cpp',
     'builtin/Profilers.cpp',
     'builtin/Promise.cpp',
     'builtin/Reflect.cpp',
     'builtin/ReflectParse.cpp',
     'builtin/SIMD.cpp',
     'builtin/Stream.cpp',
-    'builtin/String.cpp',
-    'builtin/Symbol.cpp',
+    'builtin/SymbolObject.cpp',
     'builtin/TestingFunctions.cpp',
     'builtin/TypedObject.cpp',
-    'builtin/WeakMap.cpp',
-    'builtin/WeakSet.cpp',
+    'builtin/WeakMapObject.cpp',
+    'builtin/WeakSetObject.cpp',
     'devtools/sharkctl.cpp',
     'ds/Bitmap.cpp',
     'ds/LifoAlloc.cpp',
     'ds/MemoryProtectionExceptionHandler.cpp',
     'frontend/BytecodeCompiler.cpp',
     'frontend/BytecodeEmitter.cpp',
     'frontend/FoldConstants.cpp',
     'frontend/NameFunctions.cpp',
@@ -281,35 +281,36 @@ UNIFIED_SOURCES += [
     'jit/Snapshots.cpp',
     'jit/StupidAllocator.cpp',
     'jit/TypedObjectPrediction.cpp',
     'jit/TypePolicy.cpp',
     'jit/ValueNumbering.cpp',
     'jit/VMFunctions.cpp',
     'jit/WasmBCE.cpp',
     'jsapi.cpp',
+    'jsbool.cpp',
+    'jsdate.cpp',
     'jsexn.cpp',
     'jsfriendapi.cpp',
+    'jsnum.cpp',
+    'jsstr.cpp',
     'perf/jsperf.cpp',
     'proxy/BaseProxyHandler.cpp',
     'proxy/CrossCompartmentWrapper.cpp',
     'proxy/DeadObjectProxy.cpp',
     'proxy/OpaqueCrossCompartmentWrapper.cpp',
     'proxy/Proxy.cpp',
     'proxy/ScriptedProxyHandler.cpp',
     'proxy/SecurityWrapper.cpp',
     'proxy/Wrapper.cpp',
     'threading/Mutex.cpp',
     'threading/ProtectedData.cpp',
     'util/AllocPolicy.cpp',
     'util/NativeStack.cpp',
     'util/Printf.cpp',
-    'util/StringBuffer.cpp',
-    'util/Text.cpp',
-    'util/Unicode.cpp',
     'vm/ArgumentsObject.cpp',
     'vm/ArrayBufferObject.cpp',
     'vm/AsyncFunction.cpp',
     'vm/AsyncIteration.cpp',
     'vm/BytecodeUtil.cpp',
     'vm/Caches.cpp',
     'vm/CallNonGenericMethod.cpp',
     'vm/CharacterEncoding.cpp',
@@ -351,27 +352,29 @@ UNIFIED_SOURCES += [
     'vm/SavedStacks.cpp',
     'vm/Scope.cpp',
     'vm/SelfHosting.cpp',
     'vm/Shape.cpp',
     'vm/SharedArrayObject.cpp',
     'vm/SharedImmutableStringsCache.cpp',
     'vm/Stack.cpp',
     'vm/Stopwatch.cpp',
-    'vm/StringType.cpp',
+    'vm/String.cpp',
+    'vm/StringBuffer.cpp',
     'vm/StructuredClone.cpp',
-    'vm/SymbolType.cpp',
+    'vm/Symbol.cpp',
     'vm/TaggedProto.cpp',
     'vm/Time.cpp',
     'vm/TypedArrayObject.cpp',
     'vm/TypeInference.cpp',
     'vm/UbiNode.cpp',
     'vm/UbiNodeCensus.cpp',
     'vm/UbiNodeShortestPaths.cpp',
     'vm/UnboxedObject.cpp',
+    'vm/Unicode.cpp',
     'vm/Value.cpp',
     'vm/Xdr.cpp',
     'wasm/AsmJS.cpp',
     'wasm/WasmBaselineCompile.cpp',
     'wasm/WasmBinaryIterator.cpp',
     'wasm/WasmBinaryToAST.cpp',
     'wasm/WasmBinaryToText.cpp',
     'wasm/WasmBuiltins.cpp',
@@ -390,39 +393,39 @@ UNIFIED_SOURCES += [
     'wasm/WasmStubs.cpp',
     'wasm/WasmTable.cpp',
     'wasm/WasmTextToBinary.cpp',
     'wasm/WasmTextUtils.cpp',
     'wasm/WasmTypes.cpp',
     'wasm/WasmValidate.cpp'
 ]
 
-# builtin/Array.cpp and vm/JSAtom.cpp cannot be built in unified mode because
+# jsarray.cpp and vm/JSAtom.cpp cannot be built in unified mode because
 #   xpcshell is broken during packaging when compiled with gcc-4.8.2
-# builtin/Math.cpp cannot be built in unified mode because it needs to re-#define the
-#   RtlGenRandom declaration's calling convention in <ntsecapi.h> on Windows.
 # builtin/RegExp.cpp cannot be built in unified mode because it is built
 #   without PGO
 # frontend/Parser.cpp cannot be built in unified mode because of explicit
 #   template instantiations.
+# jsmath.cpp cannot be built in unified mode because it needs to re-#define the
+#   RtlGenRandom declaration's calling convention in <ntsecapi.h> on Windows.
 # jsutil.cpp cannot be built in unified mode because it is needed for
 #   check-vanilla-allocations.
 # StoreBuffer.cpp cannot be built in unified because its template
 #   instantiations may or may not be needed depending on what it gets bundled
 #   with.
 # util/DoubleToString.cpp cannot be built in unified mode because we want to
 #   suppress compiler warnings in third-party dtoa.c.
 # vm/Interpreter.cpp is gigantic and destroys incremental build times for any
 #   files unlucky enough to be unified with it.
 SOURCES += [
-    'builtin/Array.cpp',
-    'builtin/Math.cpp',
     'builtin/RegExp.cpp',
     'frontend/Parser.cpp',
     'gc/StoreBuffer.cpp',
+    'jsarray.cpp',
+    'jsmath.cpp',
     'jsutil.cpp',
     'util/DoubleToString.cpp',
     'vm/Interpreter.cpp',
     'vm/JSAtom.cpp',
 ]
 
 if CONFIG['JS_POSIX_NSPR']:
     UNIFIED_SOURCES += [
@@ -742,17 +745,17 @@ selfhosted.inputs = [
     'builtin/Date.js',
     'builtin/Error.js',
     'builtin/Function.js',
     'builtin/Generator.js',
     'builtin/intl/Collator.js',
     'builtin/intl/CommonFunctions.js',
     'builtin/intl/CurrencyDataGenerated.js',
     'builtin/intl/DateTimeFormat.js',
-    'builtin/intl/Intl.js',
+    'builtin/intl/IntlObject.js',
     'builtin/intl/LangTagMappingsGenerated.js',
     'builtin/intl/NumberFormat.js',
     'builtin/intl/PluralRules.js',
     'builtin/intl/RelativeTimeFormat.js',
     'builtin/Iterator.js',
     'builtin/Map.js',
     'builtin/Module.js',
     'builtin/Number.js',
--- a/js/src/proxy/SecurityWrapper.cpp
+++ b/js/src/proxy/SecurityWrapper.cpp
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
 #include "NamespaceImports.h"
 
 #include "js/Wrapper.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 
 using namespace js;
 
 template <class Base>
 bool
 SecurityWrapper<Base>::enter(JSContext* cx, HandleObject wrapper, HandleId id,
                              Wrapper::Action act, bool mayThrow, bool* bp) const
 {
--- a/js/src/shell/OSObject.cpp
+++ b/js/src/shell/OSObject.cpp
@@ -17,26 +17,25 @@
 #else
 #include <sys/wait.h>
 #include <unistd.h>
 #endif
 
 #include "jsapi.h"
 // For JSFunctionSpecWithHelp
 #include "jsfriendapi.h"
+#include "jsstr.h"
 
-#include "builtin/String.h"
 #include "gc/FreeOp.h"
 #include "js/Conversions.h"
 #include "js/Wrapper.h"
 #include "shell/jsshell.h"
-#include "util/StringBuffer.h"
-#include "util/Text.h"
 #include "util/Windows.h"
 #include "vm/JSObject.h"
+#include "vm/StringBuffer.h"
 #include "vm/TypedArrayObject.h"
 
 #include "vm/JSObject-inl.h"
 
 #ifdef XP_WIN
 # ifndef PATH_MAX
 #  define PATH_MAX (MAX_PATH > _MAX_DIR ? MAX_PATH : _MAX_DIR)
 # endif
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -46,26 +46,26 @@
 #ifdef XP_UNIX
 # include <sys/mman.h>
 # include <sys/stat.h>
 # include <sys/wait.h>
 # include <unistd.h>
 #endif
 
 #include "jsapi.h"
+#include "jsarray.h"
 #include "jsfriendapi.h"
 #include "jstypes.h"
 #include "jsutil.h"
 #ifndef JS_POSIX_NSPR
 # include "prerror.h"
 # include "prlink.h"
 #endif
 #include "shellmoduleloader.out.h"
 
-#include "builtin/Array.h"
 #include "builtin/ModuleObject.h"
 #include "builtin/RegExp.h"
 #include "builtin/TestingFunctions.h"
 #if defined(JS_BUILD_BINAST)
 # include "frontend/BinSource.h"
 #endif // defined(JS_BUILD_BINAST)
 #include "frontend/Parser.h"
 #include "gc/PublicIterators.h"
@@ -85,33 +85,32 @@
 #include "perf/jsperf.h"
 #include "shell/jsoptparse.h"
 #include "shell/jsshell.h"
 #include "shell/OSObject.h"
 #include "threading/ConditionVariable.h"
 #include "threading/ExclusiveData.h"
 #include "threading/LockGuard.h"
 #include "threading/Thread.h"
-#include "util/StringBuffer.h"
-#include "util/Text.h"
 #include "util/Windows.h"
 #include "vm/ArgumentsObject.h"
 #include "vm/Compression.h"
 #include "vm/Debugger.h"
 #include "vm/HelperThreads.h"
 #include "vm/JSAtom.h"
 #include "vm/JSContext.h"
 #include "vm/JSFunction.h"
 #include "vm/JSObject.h"
 #include "vm/JSScript.h"
 #include "vm/Monitor.h"
 #include "vm/MutexIDs.h"
 #include "vm/Printer.h"
 #include "vm/Shape.h"
 #include "vm/SharedArrayObject.h"
+#include "vm/StringBuffer.h"
 #include "vm/Time.h"
 #include "vm/TypedArrayObject.h"
 #include "vm/WrapperObject.h"
 #include "wasm/WasmJS.h"
 
 #include "vm/ErrorObject-inl.h"
 #include "vm/Interpreter-inl.h"
 #include "vm/JSCompartment-inl.h"
--- a/js/src/shell/jsshell.cpp
+++ b/js/src/shell/jsshell.cpp
@@ -8,17 +8,17 @@
 
 #include "shell/jsshell.h"
 
 #include "mozilla/Sprintf.h"
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
 
-#include "util/StringBuffer.h"
+#include "vm/StringBuffer.h"
 
 using namespace JS;
 
 namespace js {
 namespace shell {
 
 // Generate 'usage' and 'help' properties for the given object.
 // JS_DefineFunctionsWithHelp will define individual function objects with both
deleted file mode 100644
--- a/js/src/util/Text.cpp
+++ /dev/null
@@ -1,332 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: set ts=8 sts=4 et sw=4 tw=99:
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "util/Text.h"
-
-#include "mozilla/PodOperations.h"
-
-#include "gc/GC.h"
-#include "js/GCAPI.h"
-#include "vm/JSContext.h"
-#include "vm/StringType.h"
-
-using namespace JS;
-using namespace js;
-using js::gc::AutoSuppressGC;
-using mozilla::PodCopy;
-
-template <typename CharT>
-const CharT*
-js_strchr_limit(const CharT* s, char16_t c, const CharT* limit)
-{
-    while (s < limit) {
-        if (*s == c)
-            return s;
-        s++;
-    }
-    return nullptr;
-}
-
-template const Latin1Char*
-js_strchr_limit(const Latin1Char* s, char16_t c, const Latin1Char* limit);
-
-template const char16_t*
-js_strchr_limit(const char16_t* s, char16_t c, const char16_t* limit);
-
-JS_PUBLIC_API(char*)
-js_strdup(const char* s)
-{
-    return DuplicateString(s).release();
-}
-
-int32_t
-js_fputs(const char16_t* s, FILE* f)
-{
-    while (*s != 0) {
-        if (fputwc(wchar_t(*s), f) == WEOF)
-            return WEOF;
-        s++;
-    }
-    return 1;
-}
-
-UniqueChars
-js::DuplicateString(JSContext* cx, const char* s)
-{
-    size_t n = strlen(s) + 1;
-    auto ret = cx->make_pod_array<char>(n);
-    if (!ret)
-        return ret;
-    PodCopy(ret.get(), s, n);
-    return ret;
-}
-
-UniqueTwoByteChars
-js::DuplicateString(JSContext* cx, const char16_t* s)
-{
-    size_t n = js_strlen(s) + 1;
-    auto ret = cx->make_pod_array<char16_t>(n);
-    if (!ret)
-        return ret;
-    PodCopy(ret.get(), s, n);
-    return ret;
-}
-
-UniqueChars
-js::DuplicateString(const char* s)
-{
-    size_t n = strlen(s) + 1;
-    UniqueChars ret(js_pod_malloc<char>(n));
-    if (!ret)
-        return ret;
-    PodCopy(ret.get(), s, n);
-    return ret;
-}
-
-UniqueChars
-js::DuplicateString(const char* s, size_t n)
-{
-    UniqueChars ret(js_pod_malloc<char>(n + 1));
-    if (!ret)
-        return nullptr;
-    PodCopy(ret.get(), s, n);
-    ret[n] = 0;
-    return ret;
-}
-
-UniqueTwoByteChars
-js::DuplicateString(const char16_t* s)
-{
-    return DuplicateString(s, js_strlen(s));
-}
-
-UniqueTwoByteChars
-js::DuplicateString(const char16_t* s, size_t n)
-{
-    UniqueTwoByteChars ret(js_pod_malloc<char16_t>(n + 1));
-    if (!ret)
-        return nullptr;
-    PodCopy(ret.get(), s, n);
-    ret[n] = 0;
-    return ret;
-}
-
-char16_t*
-js::InflateString(JSContext* cx, const char* bytes, size_t length)
-{
-    char16_t* chars = cx->pod_malloc<char16_t>(length + 1);
-    if (!chars)
-        return nullptr;
-    CopyAndInflateChars(chars, bytes, length);
-    chars[length] = 0;
-    return chars;
-}
-
-template <typename CharT>
-bool
-js::DeflateStringToBuffer(JSContext* maybecx, const CharT* src, size_t srclen,
-                          char* dst, size_t* dstlenp)
-{
-    size_t dstlen = *dstlenp;
-    if (srclen > dstlen) {
-        for (size_t i = 0; i < dstlen; i++)
-            dst[i] = char(src[i]);
-        if (maybecx) {
-            AutoSuppressGC suppress(maybecx);
-            JS_ReportErrorNumberASCII(maybecx, GetErrorMessage, nullptr,
-                                      JSMSG_BUFFER_TOO_SMALL);
-        }
-        return false;
-    }
-    for (size_t i = 0; i < srclen; i++)
-        dst[i] = char(src[i]);
-    *dstlenp = srclen;
-    return true;
-}
-
-template bool
-js::DeflateStringToBuffer(JSContext* maybecx, const Latin1Char* src, size_t srclen,
-                          char* dst, size_t* dstlenp);
-
-template bool
-js::DeflateStringToBuffer(JSContext* maybecx, const char16_t* src, size_t srclen,
-                          char* dst, size_t* dstlenp);
-
-/*
- * Convert one UCS-4 char and write it into a UTF-8 buffer, which must be at
- * least 4 bytes long.  Return the number of UTF-8 bytes of data written.
- */
-uint32_t
-js::OneUcs4ToUtf8Char(uint8_t* utf8Buffer, uint32_t ucs4Char)
-{
-    MOZ_ASSERT(ucs4Char <= unicode::NonBMPMax);
-
-    if (ucs4Char < 0x80) {
-        utf8Buffer[0] = uint8_t(ucs4Char);
-        return 1;
-    }
-
-    uint32_t a = ucs4Char >> 11;
-    uint32_t utf8Length = 2;
-    while (a) {
-        a >>= 5;
-        utf8Length++;
-    }
-
-    MOZ_ASSERT(utf8Length <= 4);
-
-    uint32_t i = utf8Length;
-    while (--i) {
-        utf8Buffer[i] = uint8_t((ucs4Char & 0x3F) | 0x80);
-        ucs4Char >>= 6;
-    }
-
-    utf8Buffer[0] = uint8_t(0x100 - (1 << (8 - utf8Length)) + ucs4Char);
-    return utf8Length;
-}
-
-size_t
-js::PutEscapedStringImpl(char* buffer, size_t bufferSize, GenericPrinter* out, JSLinearString* str,
-                         uint32_t quote)
-{
-    size_t len = str->length();
-    AutoCheckCannotGC nogc;
-    return str->hasLatin1Chars()
-           ? PutEscapedStringImpl(buffer, bufferSize, out, str->latin1Chars(nogc), len, quote)
-           : PutEscapedStringImpl(buffer, bufferSize, out, str->twoByteChars(nogc), len, quote);
-}
-
-template <typename CharT>
-size_t
-js::PutEscapedStringImpl(char* buffer, size_t bufferSize, GenericPrinter* out, const CharT* chars,
-                         size_t length, uint32_t quote)
-{
-    enum {
-        STOP, FIRST_QUOTE, LAST_QUOTE, CHARS, ESCAPE_START, ESCAPE_MORE
-    } state;
-
-    MOZ_ASSERT(quote == 0 || quote == '\'' || quote == '"');
-    MOZ_ASSERT_IF(!buffer, bufferSize == 0);
-    MOZ_ASSERT_IF(out, !buffer);
-
-    if (bufferSize == 0)
-        buffer = nullptr;
-    else
-        bufferSize--;
-
-    const CharT* charsEnd = chars + length;
-    size_t n = 0;
-    state = FIRST_QUOTE;
-    unsigned shift = 0;
-    unsigned hex = 0;
-    unsigned u = 0;
-    char c = 0;  /* to quell GCC warnings */
-
-    for (;;) {
-        switch (state) {
-          case STOP:
-            goto stop;
-          case FIRST_QUOTE:
-            state = CHARS;
-            goto do_quote;
-          case LAST_QUOTE:
-            state = STOP;
-          do_quote:
-            if (quote == 0)
-                continue;
-            c = (char)quote;
-            break;
-          case CHARS:
-            if (chars == charsEnd) {
-                state = LAST_QUOTE;
-                continue;
-            }
-            u = *chars++;
-            if (u < ' ') {
-                if (u != 0) {
-                    const char* escape = strchr(js_EscapeMap, (int)u);
-                    if (escape) {
-                        u = escape[1];
-                        goto do_escape;
-                    }
-                }
-                goto do_hex_escape;
-            }
-            if (u < 127) {
-                if (u == quote || u == '\\')
-                    goto do_escape;
-                c = (char)u;
-            } else if (u < 0x100) {
-                goto do_hex_escape;
-            } else {
-                shift = 16;
-                hex = u;
-                u = 'u';
-                goto do_escape;
-            }
-            break;
-          do_hex_escape:
-            shift = 8;
-            hex = u;
-            u = 'x';
-          do_escape:
-            c = '\\';
-            state = ESCAPE_START;
-            break;
-          case ESCAPE_START:
-            MOZ_ASSERT(' ' <= u && u < 127);
-            c = (char)u;
-            state = ESCAPE_MORE;
-            break;
-          case ESCAPE_MORE:
-            if (shift == 0) {
-                state = CHARS;
-                continue;
-            }
-            shift -= 4;
-            u = 0xF & (hex >> shift);
-            c = (char)(u + (u < 10 ? '0' : 'A' - 10));
-            break;
-        }
-        if (buffer) {
-            MOZ_ASSERT(n <= bufferSize);
-            if (n != bufferSize) {
-                buffer[n] = c;
-            } else {
-                buffer[n] = '\0';
-                buffer = nullptr;
-            }
-        } else if (out) {
-            if (!out->put(&c, 1))
-                return size_t(-1);
-        }
-        n++;
-    }
-  stop:
-    if (buffer)
-        buffer[n] = '\0';
-    return n;
-}
-
-template size_t
-js::PutEscapedStringImpl(char* buffer, size_t bufferSize, GenericPrinter* out, const Latin1Char* chars,
-                         size_t length, uint32_t quote);
-
-template size_t
-js::PutEscapedStringImpl(char* buffer, size_t bufferSize, GenericPrinter* out, const char* chars,
-                         size_t length, uint32_t quote);
-
-template size_t
-js::PutEscapedStringImpl(char* buffer, size_t bufferSize, GenericPrinter* out, const char16_t* chars,
-                         size_t length, uint32_t quote);
-
-template size_t
-js::PutEscapedString(char* buffer, size_t bufferSize, const Latin1Char* chars, size_t length,
-                     uint32_t quote);
-
-template size_t
-js::PutEscapedString(char* buffer, size_t bufferSize, const char16_t* chars, size_t length,
-                     uint32_t quote);
deleted file mode 100644
--- a/js/src/util/Text.h
+++ /dev/null
@@ -1,253 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: set ts=8 sts=4 et sw=4 tw=99:
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef util_Text_h
-#define util_Text_h
-
-#include "mozilla/Assertions.h"
-#include "mozilla/Attributes.h"
-
-#include <ctype.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string>
-
-#include "jsutil.h"
-#include "NamespaceImports.h"
-
-#include "js/Utility.h"
-#include "util/Unicode.h"
-#include "vm/Printer.h"
-
-class JSLinearString;
-
-/*
- * Shorthands for ASCII (7-bit) decimal and hex conversion.
- * Manually inline isdigit and isxdigit for performance; MSVC doesn't do this for us.
- */
-#define JS7_ISDEC(c)    ((((unsigned)(c)) - '0') <= 9)
-#define JS7_ISA2F(c)    ((((((unsigned)(c)) - 'a') <= 5) || (((unsigned)(c)) - 'A') <= 5))
-#define JS7_UNDEC(c)    ((c) - '0')
-#define JS7_ISOCT(c)    ((((unsigned)(c)) - '0') <= 7)
-#define JS7_UNOCT(c)    (JS7_UNDEC(c))
-#define JS7_ISHEX(c)    ((c) < 128 && (JS7_ISDEC(c) || JS7_ISA2F(c)))
-#define JS7_UNHEX(c)    (unsigned)(JS7_ISDEC(c) ? (c) - '0' : 10 + tolower(c) - 'a')
-#define JS7_ISLET(c)    ((c) < 128 && isalpha(c))
-
-static MOZ_ALWAYS_INLINE size_t
-js_strlen(const char16_t* s)
-{
-    return std::char_traits<char16_t>::length(s);
-}
-
-template <typename CharT>
-extern const CharT*
-js_strchr_limit(const CharT* s, char16_t c, const CharT* limit);
-
-extern int32_t
-js_fputs(const char16_t* s, FILE* f);
-
-namespace js {
-
-class StringBuffer;
-
-template <typename Char1, typename Char2>
-inline bool
-EqualChars(const Char1* s1, const Char2* s2, size_t len);
-
-template <typename Char1>
-inline bool
-EqualChars(const Char1* s1, const Char1* s2, size_t len)
-{
-    return mozilla::PodEqual(s1, s2, len);
-}
-
-template <typename Char1, typename Char2>
-inline bool
-EqualChars(const Char1* s1, const Char2* s2, size_t len)
-{
-    for (const Char1* s1end = s1 + len; s1 < s1end; s1++, s2++) {
-        if (*s1 != *s2)
-            return false;
-    }
-    return true;
-}
-
-// Return less than, equal to, or greater than zero depending on whether
-// s1 is less than, equal to, or greater than s2.
-template <typename Char1, typename Char2>
-inline int32_t
-CompareChars(const Char1* s1, size_t len1, const Char2* s2, size_t len2)
-{
-    size_t n = Min(len1, len2);
-    for (size_t i = 0; i < n; i++) {
-        if (int32_t cmp = s1[i] - s2[i])
-            return cmp;
-    }
-
-    return int32_t(len1 - len2);
-}
-
-// Return s advanced past any Unicode white space characters.
-template <typename CharT>
-static inline const CharT*
-SkipSpace(const CharT* s, const CharT* end)
-{
-    MOZ_ASSERT(s <= end);
-
-    while (s < end && unicode::IsSpace(*s))
-        s++;
-
-    return s;
-}
-
-extern UniqueChars
-DuplicateString(JSContext* cx, const char* s);
-
-extern UniqueTwoByteChars
-DuplicateString(JSContext* cx, const char16_t* s);
-
-/*
- * These variants do not report OOMs, you must arrange for OOMs to be reported
- * yourself.
- */
-extern UniqueChars
-DuplicateString(const char* s);
-
-extern UniqueChars
-DuplicateString(const char* s, size_t n);
-
-extern UniqueTwoByteChars
-DuplicateString(const char16_t* s);
-
-extern UniqueTwoByteChars
-DuplicateString(const char16_t* s, size_t n);
-
-/*
- * Inflate bytes in ASCII encoding to char16_t code units. Return null on error,
- * otherwise return the char16_t buffer that was malloc'ed. A null char is
- * appended.
- */
-extern char16_t*
-InflateString(JSContext* cx, const char* bytes, size_t length);
-
-/*
- * Inflate bytes to JS chars in an existing buffer. 'dst' must be large
- * enough for 'srclen' char16_t code units. The buffer is NOT null-terminated.
- */
-inline void
-CopyAndInflateChars(char16_t* dst, const char* src, size_t srclen)
-{
-    for (size_t i = 0; i < srclen; i++)
-        dst[i] = (unsigned char) src[i];
-}
-
-inline void
-CopyAndInflateChars(char16_t* dst, const JS::Latin1Char* src, size_t srclen)
-{
-    for (size_t i = 0; i < srclen; i++)
-        dst[i] = src[i];
-}
-
-/*
- * Deflate JS chars to bytes into a buffer. 'bytes' must be large enough for
- * 'length chars. The buffer is NOT null-terminated. The destination length
- * must to be initialized with the buffer size and will contain on return the
- * number of copied bytes.
- */
-template <typename CharT>
-extern bool
-DeflateStringToBuffer(JSContext* maybecx, const CharT* chars,
-                      size_t charsLength, char* bytes, size_t* length);
-
-/*
- * Convert one UCS-4 char and write it into a UTF-8 buffer, which must be at
- * least 4 bytes long.  Return the number of UTF-8 bytes of data written.
- */
-extern uint32_t
-OneUcs4ToUtf8Char(uint8_t* utf8Buffer, uint32_t ucs4Char);
-
-extern size_t
-PutEscapedStringImpl(char* buffer, size_t size, GenericPrinter* out, JSLinearString* str,
-                     uint32_t quote);
-
-template <typename CharT>
-extern size_t
-PutEscapedStringImpl(char* buffer, size_t bufferSize, GenericPrinter* out, const CharT* chars,
-                     size_t length, uint32_t quote);
-
-/*
- * Write str into buffer escaping any non-printable or non-ASCII character
- * using \escapes for JS string literals.
- * Guarantees that a NUL is at the end of the buffer unless size is 0. Returns
- * the length of the written output, NOT including the NUL. Thus, a return
- * value of size or more means that the output was truncated. If buffer
- * is null, just returns the length of the output. If quote is not 0, it must
- * be a single or double quote character that will quote the output.
-*/
-inline size_t
-PutEscapedString(char* buffer, size_t size, JSLinearString* str, uint32_t quote)
-{
-    size_t n = PutEscapedStringImpl(buffer, size, nullptr, str, quote);
-
-    /* PutEscapedStringImpl can only fail with a file. */
-    MOZ_ASSERT(n != size_t(-1));
-    return n;
-}
-
-template <typename CharT>
-inline size_t
-PutEscapedString(char* buffer, size_t bufferSize, const CharT* chars, size_t length, uint32_t quote)
-{
-    size_t n = PutEscapedStringImpl(buffer, bufferSize, nullptr, chars, length, quote);
-
-    /* PutEscapedStringImpl can only fail with a file. */
-    MOZ_ASSERT(n != size_t(-1));
-    return n;
-}
-
-inline bool
-EscapedStringPrinter(GenericPrinter& out, JSLinearString* str, uint32_t quote)
-{
-    return PutEscapedStringImpl(nullptr, 0, &out, str, quote) != size_t(-1);
-}
-
-inline bool
-EscapedStringPrinter(GenericPrinter& out, const char* chars, size_t length, uint32_t quote)
-{
-    return PutEscapedStringImpl(nullptr, 0, &out, chars, length, quote) != size_t(-1);
-}
-
-/*
- * Write str into file escaping any non-printable or non-ASCII character.
- * If quote is not 0, it must be a single or double quote character that
- * will quote the output.
-*/
-inline bool
-FileEscapedString(FILE* fp, JSLinearString* str, uint32_t quote)
-{
-    Fprinter out(fp);
-    bool res = EscapedStringPrinter(out, str, quote);
-    out.finish();
-    return res;
-}
-
-inline bool
-FileEscapedString(FILE* fp, const char* chars, size_t length, uint32_t quote)
-{
-    Fprinter out(fp);
-    bool res = EscapedStringPrinter(out, chars, length, quote);
-    out.finish();
-    return res;
-}
-
-bool
-EncodeURI(JSContext* cx, StringBuffer& sb, const char* chars, size_t length);
-
-} // namespace js
-
-#endif // util_Text_h
--- a/js/src/vm/ArrayBufferObject.cpp
+++ b/js/src/vm/ArrayBufferObject.cpp
@@ -18,23 +18,23 @@
 #ifndef XP_WIN
 # include <sys/mman.h>
 #endif
 #ifdef MOZ_VALGRIND
 # include <valgrind/memcheck.h>
 #endif
 
 #include "jsapi.h"
+#include "jsarray.h"
 #include "jsfriendapi.h"
+#include "jsnum.h"
 #include "jstypes.h"
 #include "jsutil.h"
 
-#include "builtin/Array.h"
-#include "builtin/DataView.h"
-#include "builtin/Number.h"
+#include "builtin/DataViewObject.h"
 #include "gc/Barrier.h"
 #include "gc/FreeOp.h"
 #include "gc/Memory.h"
 #include "js/Conversions.h"
 #include "js/MemoryMetrics.h"
 #include "js/Wrapper.h"
 #include "util/Windows.h"
 #include "vm/GlobalObject.h"
--- a/js/src/vm/ArrayObject-inl.h
+++ b/js/src/vm/ArrayObject-inl.h
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef vm_ArrayObject_inl_h
 #define vm_ArrayObject_inl_h
 
 #include "vm/ArrayObject.h"
 
 #include "gc/GCTrace.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 
 #include "vm/JSObject-inl.h"
 #include "vm/TypeInference-inl.h"
 
 namespace js {
 
 inline void
 ArrayObject::setLength(JSContext* cx, uint32_t length)
--- a/js/src/vm/AsyncIteration.cpp
+++ b/js/src/vm/AsyncIteration.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "vm/AsyncIteration.h"
 
-#include "builtin/Array.h"
+#include "jsarray.h"
 
 #include "builtin/Promise.h"
 #include "vm/GeneratorObject.h"
 #include "vm/GlobalObject.h"
 #include "vm/Interpreter.h"
 #include "vm/JSCompartment.h"
 #include "vm/SelfHosting.h"
 
--- a/js/src/vm/BooleanObject.h
+++ b/js/src/vm/BooleanObject.h
@@ -2,17 +2,17 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef vm_BooleanObject_h
 #define vm_BooleanObject_h
 
-#include "builtin/Boolean.h"
+#include "jsbool.h"
 
 #include "vm/NativeObject.h"
 
 namespace js {
 
 class BooleanObject : public NativeObject
 {
     /* Stores this Boolean object's [[PrimitiveValue]]. */
--- a/js/src/vm/BytecodeUtil.cpp
+++ b/js/src/vm/BytecodeUtil.cpp
@@ -19,38 +19,38 @@
 
 #include <algorithm>
 #include <ctype.h>
 #include <inttypes.h>
 #include <stdio.h>
 #include <string.h>
 
 #include "jsapi.h"
+#include "jsnum.h"
+#include "jsstr.h"
 #include "jstypes.h"
 #include "jsutil.h"
 
-#include "builtin/Number.h"
-#include "builtin/String.h"
 #include "frontend/BytecodeCompiler.h"
 #include "frontend/SourceNotes.h"
 #include "gc/FreeOp.h"
 #include "gc/GCInternals.h"
 #include "js/CharacterEncoding.h"
 #include "js/Printf.h"
-#include "util/StringBuffer.h"
 #include "vm/CodeCoverage.h"
 #include "vm/EnvironmentObject.h"
 #include "vm/JSAtom.h"
 #include "vm/JSCompartment.h"
 #include "vm/JSContext.h"
 #include "vm/JSFunction.h"
 #include "vm/JSObject.h"
 #include "vm/JSScript.h"
 #include "vm/Opcodes.h"
 #include "vm/Shape.h"
+#include "vm/StringBuffer.h"
 
 #include "gc/PrivateIterators-inl.h"
 #include "vm/JSCompartment-inl.h"
 #include "vm/JSContext-inl.h"
 #include "vm/JSObject-inl.h"
 #include "vm/JSScript-inl.h"
 
 using namespace js;
--- a/js/src/vm/Caches.h
+++ b/js/src/vm/Caches.h
@@ -2,17 +2,17 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef vm_Caches_h
 #define vm_Caches_h
 
-#include "builtin/Math.h"
+#include "jsmath.h"
 
 #include "frontend/SourceNotes.h"
 #include "gc/Tracer.h"
 #include "js/RootingAPI.h"
 #include "js/TypeDecls.h"
 #include "js/UniquePtr.h"
 #include "vm/ArrayObject.h"
 #include "vm/JSAtom.h"
--- a/js/src/vm/CodeCoverage.cpp
+++ b/js/src/vm/CodeCoverage.cpp
@@ -13,17 +13,16 @@
 #include <stdio.h>
 #ifdef XP_WIN
 # include <process.h>
 # define getpid _getpid
 #else
 # include <unistd.h>
 #endif
 
-#include "util/Text.h"
 #include "vm/BytecodeUtil.h"
 #include "vm/JSCompartment.h"
 #include "vm/JSScript.h"
 #include "vm/Runtime.h"
 #include "vm/Time.h"
 
 // This file contains a few functions which are used to produce files understood
 // by lcov tools. A detailed description of the format is available in the man
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -7,18 +7,18 @@
 #include "vm/Debugger-inl.h"
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/ScopeExit.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/TypeTraits.h"
 
 #include "jsfriendapi.h"
-
-#include "builtin/Number.h"
+#include "jsnum.h"
+
 #include "frontend/BytecodeCompiler.h"
 #include "frontend/Parser.h"
 #include "gc/FreeOp.h"
 #include "gc/HashUtil.h"
 #include "gc/Marking.h"
 #include "gc/Policy.h"
 #include "gc/PublicIterators.h"
 #include "jit/BaselineDebugModeOSR.h"
--- a/js/src/vm/DebuggerMemory.cpp
+++ b/js/src/vm/DebuggerMemory.cpp
@@ -7,17 +7,17 @@
 #include "vm/DebuggerMemory.h"
 
 #include "mozilla/Maybe.h"
 #include "mozilla/Move.h"
 #include "mozilla/Vector.h"
 
 #include <stdlib.h>
 
-#include "builtin/Map.h"
+#include "builtin/MapObject.h"
 #include "gc/Marking.h"
 #include "js/AllocPolicy.h"
 #include "js/Debug.h"
 #include "js/TracingAPI.h"
 #include "js/UbiNode.h"
 #include "js/UbiNodeCensus.h"
 #include "js/Utility.h"
 #include "vm/Debugger.h"
--- a/js/src/vm/ErrorObject.cpp
+++ b/js/src/vm/ErrorObject.cpp
@@ -9,17 +9,17 @@
 
 #include "mozilla/Range.h"
 
 #include "jsexn.h"
 
 #include "js/CallArgs.h"
 #include "js/CharacterEncoding.h"
 #include "vm/GlobalObject.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 
 #include "vm/JSObject-inl.h"
 #include "vm/NativeObject-inl.h"
 #include "vm/SavedStacks-inl.h"
 #include "vm/Shape-inl.h"
 
 using namespace js;
 
--- a/js/src/vm/GeckoProfiler.cpp
+++ b/js/src/vm/GeckoProfiler.cpp
@@ -3,25 +3,26 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "vm/GeckoProfiler-inl.h"
 
 #include "mozilla/DebugOnly.h"
 
-#include "builtin/Number.h"
+#include "jsnum.h"
+
 #include "gc/PublicIterators.h"
 #include "jit/BaselineFrame.h"
 #include "jit/BaselineJIT.h"
 #include "jit/JitcodeMap.h"
 #include "jit/JitFrames.h"
 #include "jit/JSJitFrameIter.h"
-#include "util/StringBuffer.h"
 #include "vm/JSScript.h"
+#include "vm/StringBuffer.h"
 
 #include "gc/Marking-inl.h"
 
 using namespace js;
 
 using mozilla::DebugOnly;
 
 GeckoProfilerThread::GeckoProfilerThread()
--- a/js/src/vm/GlobalObject.cpp
+++ b/js/src/vm/GlobalObject.cpp
@@ -1,36 +1,36 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "vm/GlobalObject.h"
 
+#include "jsdate.h"
 #include "jsexn.h"
 #include "jsfriendapi.h"
+#include "jsmath.h"
 
-#include "builtin/Atomics.h"
-#include "builtin/DataView.h"
-#include "builtin/Date.h"
+#include "builtin/AtomicsObject.h"
+#include "builtin/DataViewObject.h"
 #include "builtin/Eval.h"
 #include "builtin/JSON.h"
-#include "builtin/Map.h"
-#include "builtin/Math.h"
+#include "builtin/MapObject.h"
 #include "builtin/ModuleObject.h"
 #include "builtin/Object.h"
 #include "builtin/Promise.h"
 #include "builtin/RegExp.h"
 #include "builtin/SelfHostingDefines.h"
 #include "builtin/Stream.h"
-#include "builtin/Symbol.h"
+#include "builtin/SymbolObject.h"
 #include "builtin/TypedObject.h"
-#include "builtin/WeakMap.h"
-#include "builtin/WeakSet.h"
+#include "builtin/WeakMapObject.h"
+#include "builtin/WeakSetObject.h"
 #include "gc/FreeOp.h"
 #include "js/ProtoKey.h"
 #include "vm/Debugger.h"
 #include "vm/EnvironmentObject.h"
 #include "vm/HelperThreads.h"
 #include "vm/JSContext.h"
 #include "vm/PIC.h"
 #include "vm/RegExpStatics.h"
--- a/js/src/vm/GlobalObject.h
+++ b/js/src/vm/GlobalObject.h
@@ -2,21 +2,21 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef vm_GlobalObject_h
 #define vm_GlobalObject_h
 
+#include "jsarray.h"
+#include "jsbool.h"
 #include "jsexn.h"
+#include "jsnum.h"
 
-#include "builtin/Array.h"
-#include "builtin/Boolean.h"
-#include "builtin/Number.h"
 #include "js/Vector.h"
 #include "vm/ArrayBufferObject.h"
 #include "vm/ErrorObject.h"
 #include "vm/JSFunction.h"
 #include "vm/RegExpStatics.h"
 #include "vm/Runtime.h"
 
 namespace js {
@@ -771,21 +771,21 @@ class GlobalObject : public NativeObject
 
     // Implemented in vm/GeneratorObject.cpp.
     static bool initGenerators(JSContext* cx, Handle<GlobalObject*> global);
 
     static bool initAsyncFunction(JSContext* cx, Handle<GlobalObject*> global);
 
     static bool initAsyncGenerators(JSContext* cx, Handle<GlobalObject*> global);
 
-    // Implemented in builtin/Map.cpp.
+    // Implemented in builtin/MapObject.cpp.
     static bool initMapIteratorProto(JSContext* cx, Handle<GlobalObject*> global);
     static bool initSetIteratorProto(JSContext* cx, Handle<GlobalObject*> global);
 
-    // Implemented in builtin/intl/Intl.cpp.
+    // Implemented in builtin/intl/IntlObject.cpp.
     static bool initIntlObject(JSContext* cx, Handle<GlobalObject*> global);
 
     // Implemented in builtin/intl/RelativeTimeFormat.cpp.
     static bool addRelativeTimeFormatConstructor(JSContext* cx, HandleObject intl);
 
     // Implemented in builtin/ModuleObject.cpp
     static bool initModuleProto(JSContext* cx, Handle<GlobalObject*> global);
     static bool initImportEntryProto(JSContext* cx, Handle<GlobalObject*> global);
--- a/js/src/vm/Initialization.cpp
+++ b/js/src/vm/Initialization.cpp
@@ -9,17 +9,17 @@
 #include "js/Initialization.h"
 
 #include "mozilla/Assertions.h"
 
 #include <ctype.h>
 
 #include "jstypes.h"
 
-#include "builtin/Atomics.h"
+#include "builtin/AtomicsObject.h"
 #include "ds/MemoryProtectionExceptionHandler.h"
 #include "gc/Statistics.h"
 #include "jit/ExecutableAllocator.h"
 #include "jit/Ion.h"
 #include "jit/JitCommon.h"
 #include "js/Utility.h"
 #if ENABLE_INTL_API
 #include "unicode/uclean.h"
--- a/js/src/vm/Interpreter-inl.h
+++ b/js/src/vm/Interpreter-inl.h
@@ -4,27 +4,28 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef vm_Interpreter_inl_h
 #define vm_Interpreter_inl_h
 
 #include "vm/Interpreter.h"
 
-#include "builtin/Number.h"
-#include "builtin/String.h"
+#include "jsnum.h"
+#include "jsstr.h"
+
 #include "jit/Ion.h"
 #include "vm/ArgumentsObject.h"
 #include "vm/JSCompartment.h"
 
 #include "vm/EnvironmentObject-inl.h"
 #include "vm/JSAtom-inl.h"
 #include "vm/JSObject-inl.h"
 #include "vm/Stack-inl.h"
-#include "vm/StringType-inl.h"
+#include "vm/String-inl.h"
 #include "vm/UnboxedObject-inl.h"
 
 namespace js {
 
 /*
  * Every possible consumer of MagicValue(JS_OPTIMIZED_ARGUMENTS) (as determined
  * by ScriptAnalysis::needsArgsObj) must check for these magic values and, when
  * one is received, act as if the value were the function's ArgumentsObject.
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -12,46 +12,47 @@
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/Sprintf.h"
 
 #include <string.h>
 
-#include "builtin/Array.h"
+#include "jsarray.h"
+#include "jslibmath.h"
+#include "jsnum.h"
+#include "jsstr.h"
+
 #include "builtin/Eval.h"
-#include "builtin/Number.h"
-#include "builtin/String.h"
 #include "jit/AtomicOperations.h"
 #include "jit/BaselineJIT.h"
 #include "jit/Ion.h"
 #include "jit/IonAnalysis.h"
 #include "jit/Jit.h"
-#include "util/PortableMath.h"
-#include "util/StringBuffer.h"
 #include "vm/AsyncFunction.h"
 #include "vm/AsyncIteration.h"
 #include "vm/BytecodeUtil.h"
 #include "vm/Debugger.h"
 #include "vm/GeneratorObject.h"
 #include "vm/Iteration.h"
 #include "vm/JSAtom.h"
 #include "vm/JSContext.h"
 #include "vm/JSFunction.h"
 #include "vm/JSObject.h"
 #include "vm/JSScript.h"
 #include "vm/Opcodes.h"
 #include "vm/Scope.h"
 #include "vm/Shape.h"
 #include "vm/Stopwatch.h"
-#include "vm/StringType.h"
+#include "vm/StringBuffer.h"
 #include "vm/TraceLogging.h"
 
-#include "builtin/Boolean-inl.h"
+#include "jsboolinlines.h"
+
 #include "jit/JitFrames-inl.h"
 #include "vm/Debugger-inl.h"
 #include "vm/EnvironmentObject-inl.h"
 #include "vm/GeckoProfiler-inl.h"
 #include "vm/JSAtom-inl.h"
 #include "vm/JSFunction-inl.h"
 #include "vm/JSScript-inl.h"
 #include "vm/NativeObject-inl.h"
--- a/js/src/vm/Iteration.cpp
+++ b/js/src/vm/Iteration.cpp
@@ -9,20 +9,20 @@
 #include "vm/Iteration.h"
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/PodOperations.h"
 #include "mozilla/Unused.h"
 
+#include "jsarray.h"
 #include "jstypes.h"
 #include "jsutil.h"
 
-#include "builtin/Array.h"
 #include "ds/Sort.h"
 #include "gc/FreeOp.h"
 #include "gc/Marking.h"
 #include "js/Proxy.h"
 #include "vm/BytecodeUtil.h"
 #include "vm/GeneratorObject.h"
 #include "vm/GlobalObject.h"
 #include "vm/Interpreter.h"
@@ -32,17 +32,17 @@
 #include "vm/JSScript.h"
 #include "vm/Shape.h"
 #include "vm/TypedArrayObject.h"
 
 #include "vm/JSScript-inl.h"
 #include "vm/NativeObject-inl.h"
 #include "vm/ReceiverGuard-inl.h"
 #include "vm/Stack-inl.h"
-#include "vm/StringType-inl.h"
+#include "vm/String-inl.h"
 
 using namespace js;
 using namespace js::gc;
 
 using mozilla::DebugOnly;
 using mozilla::Maybe;
 using mozilla::PodCopy;
 using mozilla::PodEqual;
--- a/js/src/vm/JSAtom-inl.h
+++ b/js/src/vm/JSAtom-inl.h
@@ -6,19 +6,20 @@
 
 #ifndef vm_JSAtom_inl_h
 #define vm_JSAtom_inl_h
 
 #include "vm/JSAtom.h"
 
 #include "mozilla/RangedPtr.h"
 
-#include "builtin/Number.h"
+#include "jsnum.h"
+
 #include "vm/Runtime.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 
 namespace js {
 
 inline jsid
 AtomToId(JSAtom* atom)
 {
     JS_STATIC_ASSERT(JSID_INT_MIN == 0);
 
--- a/js/src/vm/JSAtom.cpp
+++ b/js/src/vm/JSAtom.cpp
@@ -12,30 +12,29 @@
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/EndianUtils.h"
 #include "mozilla/RangedPtr.h"
 #include "mozilla/Unused.h"
 
 #include <string.h>
 
+#include "jsstr.h"
 #include "jstypes.h"
 
-#include "builtin/String.h"
 #include "gc/Marking.h"
-#include "util/Text.h"
 #include "vm/JSContext.h"
-#include "vm/SymbolType.h"
+#include "vm/Symbol.h"
 #include "vm/Xdr.h"
 
 #include "gc/AtomMarking-inl.h"
 #include "vm/JSCompartment-inl.h"
 #include "vm/JSContext-inl.h"
 #include "vm/JSObject-inl.h"
-#include "vm/StringType-inl.h"
+#include "vm/String-inl.h"
 
 using namespace js;
 using namespace js::gc;
 
 using mozilla::ArrayEnd;
 using mozilla::ArrayLength;
 using mozilla::Maybe;
 using mozilla::Nothing;
--- a/js/src/vm/JSContext-inl.h
+++ b/js/src/vm/JSContext-inl.h
@@ -11,17 +11,17 @@
 
 #include "builtin/Object.h"
 #include "jit/JitFrames.h"
 #include "proxy/Proxy.h"
 #include "vm/HelperThreads.h"
 #include "vm/Interpreter.h"
 #include "vm/Iteration.h"
 #include "vm/JSCompartment.h"
-#include "vm/SymbolType.h"
+#include "vm/Symbol.h"
 
 namespace js {
 
 class CompartmentChecker
 {
     JSCompartment* compartment;
 
   public:
--- a/js/src/vm/JSContext.cpp
+++ b/js/src/vm/JSContext.cpp
@@ -25,19 +25,19 @@
 # include <string>
 #endif // ANDROID
 #ifdef XP_WIN
 # include <processthreadsapi.h>
 #endif // XP_WIN
 
 #include "jsexn.h"
 #include "jspubtd.h"
+#include "jsstr.h"
 #include "jstypes.h"
 
-#include "builtin/String.h"
 #include "gc/FreeOp.h"
 #include "gc/Marking.h"
 #include "jit/Ion.h"
 #include "jit/PcScriptCache.h"
 #include "js/CharacterEncoding.h"
 #include "js/Printf.h"
 #include "util/DoubleToString.h"
 #include "util/NativeStack.h"
--- a/js/src/vm/JSFunction.cpp
+++ b/js/src/vm/JSFunction.cpp
@@ -13,45 +13,45 @@
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/Range.h"
 
 #include <string.h>
 
 #include "jsapi.h"
+#include "jsarray.h"
+#include "jsstr.h"
 #include "jstypes.h"
 
-#include "builtin/Array.h"
 #include "builtin/Eval.h"
 #include "builtin/Object.h"
 #include "builtin/SelfHostingDefines.h"
-#include "builtin/String.h"
 #include "frontend/BytecodeCompiler.h"
 #include "frontend/TokenStream.h"
 #include "gc/Marking.h"
 #include "gc/Policy.h"
 #include "jit/InlinableNatives.h"
 #include "jit/Ion.h"
 #include "js/CallNonGenericMethod.h"
 #include "js/Proxy.h"
 #include "js/Wrapper.h"
-#include "util/StringBuffer.h"
 #include "vm/AsyncFunction.h"
 #include "vm/AsyncIteration.h"
 #include "vm/Debugger.h"
 #include "vm/GlobalObject.h"
 #include "vm/Interpreter.h"
 #include "vm/JSAtom.h"
 #include "vm/JSContext.h"
 #include "vm/JSObject.h"
 #include "vm/JSScript.h"
 #include "vm/SelfHosting.h"
 #include "vm/Shape.h"
 #include "vm/SharedImmutableStringsCache.h"
+#include "vm/StringBuffer.h"
 #include "vm/WrapperObject.h"
 #include "vm/Xdr.h"
 #include "wasm/AsmJS.h"
 
 #include "vm/Interpreter-inl.h"
 #include "vm/JSScript-inl.h"
 #include "vm/Stack-inl.h"
 
--- a/js/src/vm/JSONParser.cpp
+++ b/js/src/vm/JSONParser.cpp
@@ -7,20 +7,21 @@
 #include "vm/JSONParser.h"
 
 #include "mozilla/Range.h"
 #include "mozilla/RangedPtr.h"
 #include "mozilla/Sprintf.h"
 
 #include <ctype.h>
 
-#include "builtin/Array.h"
-#include "builtin/Number.h"
-#include "util/StringBuffer.h"
+#include "jsarray.h"
+#include "jsnum.h"
+
 #include "vm/JSCompartment.h"
+#include "vm/StringBuffer.h"
 
 #include "vm/NativeObject-inl.h"
 
 using namespace js;
 
 using mozilla::RangedPtr;
 
 JSONParserBase::~JSONParserBase()
--- a/js/src/vm/JSONParser.h
+++ b/js/src/vm/JSONParser.h
@@ -8,17 +8,17 @@
 #define vm_JSONParser_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/Range.h"
 
 #include "jspubtd.h"
 
 #include "ds/IdValuePair.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 
 namespace js {
 
 // JSONParser base class. JSONParser is templatized to work on either Latin1
 // or TwoByte input strings, JSONParserBase holds all state and methods that
 // can be shared between the two encodings.
 class MOZ_STACK_CLASS JSONParserBase
 {
--- a/js/src/vm/JSObject-inl.h
+++ b/js/src/vm/JSObject-inl.h
@@ -8,17 +8,17 @@
 #define vm_JSObject_inl_h
 
 #include "vm/JSObject.h"
 
 #include "mozilla/DebugOnly.h"
 
 #include "jsfriendapi.h"
 
-#include "builtin/Map.h"
+#include "builtin/MapObject.h"
 #include "builtin/TypedObject.h"
 #include "gc/Allocator.h"
 #include "gc/FreeOp.h"
 #include "vm/ArrayObject.h"
 #include "vm/DateObject.h"
 #include "vm/EnvironmentObject.h"
 #include "vm/JSFunction.h"
 #include "vm/NumberObject.h"
--- a/js/src/vm/JSObject.cpp
+++ b/js/src/vm/JSObject.cpp
@@ -13,51 +13,51 @@
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/TemplateLib.h"
 
 #include <string.h>
 
 #include "jsapi.h"
+#include "jsarray.h"
 #include "jsexn.h"
 #include "jsfriendapi.h"
+#include "jsnum.h"
+#include "jsstr.h"
 #include "jstypes.h"
 #include "jsutil.h"
 
-#include "builtin/Array.h"
 #include "builtin/Eval.h"
-#include "builtin/Number.h"
 #include "builtin/Object.h"
-#include "builtin/String.h"
-#include "builtin/Symbol.h"
+#include "builtin/SymbolObject.h"
 #include "frontend/BytecodeCompiler.h"
 #include "gc/Policy.h"
 #include "jit/BaselineJIT.h"
 #include "js/MemoryMetrics.h"
 #include "js/Proxy.h"
 #include "js/UbiNode.h"
 #include "js/UniquePtr.h"
 #include "js/Wrapper.h"
-#include "util/Text.h"
 #include "util/Windows.h"
 #include "vm/ArgumentsObject.h"
 #include "vm/BytecodeUtil.h"
 #include "vm/Interpreter.h"
 #include "vm/Iteration.h"
 #include "vm/JSAtom.h"
 #include "vm/JSContext.h"
 #include "vm/JSFunction.h"
 #include "vm/JSScript.h"
 #include "vm/ProxyObject.h"
 #include "vm/RegExpStaticsObject.h"
 #include "vm/Shape.h"
 #include "vm/TypedArrayObject.h"
 
-#include "builtin/Boolean-inl.h"
+#include "jsboolinlines.h"
+
 #include "builtin/TypedObject-inl.h"
 #include "gc/Marking-inl.h"
 #include "vm/ArrayObject-inl.h"
 #include "vm/BooleanObject-inl.h"
 #include "vm/Caches-inl.h"
 #include "vm/Interpreter-inl.h"
 #include "vm/JSAtom-inl.h"
 #include "vm/JSCompartment-inl.h"
--- a/js/src/vm/JSObject.h
+++ b/js/src/vm/JSObject.h
@@ -10,17 +10,17 @@
 #include "mozilla/MemoryReporting.h"
 
 #include "gc/Barrier.h"
 #include "js/Conversions.h"
 #include "js/GCVector.h"
 #include "js/HeapAPI.h"
 #include "vm/Printer.h"
 #include "vm/Shape.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 #include "vm/Xdr.h"
 
 namespace JS {
 struct ClassInfo;
 } // namespace JS
 
 namespace js {
 
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -31,30 +31,29 @@
 #include "gc/FreeOp.h"
 #include "jit/BaselineJIT.h"
 #include "jit/Ion.h"
 #include "jit/IonCode.h"
 #include "js/MemoryMetrics.h"
 #include "js/Printf.h"
 #include "js/Utility.h"
 #include "js/Wrapper.h"
-#include "util/StringBuffer.h"
-#include "util/Text.h"
 #include "vm/ArgumentsObject.h"
 #include "vm/BytecodeUtil.h"
 #include "vm/Compression.h"
 #include "vm/Debugger.h"
 #include "vm/JSAtom.h"
 #include "vm/JSContext.h"
 #include "vm/JSFunction.h"
 #include "vm/JSObject.h"
 #include "vm/Opcodes.h"
 #include "vm/SelfHosting.h"
 #include "vm/Shape.h"
 #include "vm/SharedImmutableStringsCache.h"
+#include "vm/StringBuffer.h"
 #include "vm/Xdr.h"
 #include "vtune/VTuneWrapper.h"
 
 #include "gc/Marking-inl.h"
 #include "vm/EnvironmentObject-inl.h"
 #include "vm/JSFunction-inl.h"
 #include "vm/JSObject-inl.h"
 #include "vm/NativeObject-inl.h"
--- a/js/src/vm/MemoryMetrics.cpp
+++ b/js/src/vm/MemoryMetrics.cpp
@@ -13,18 +13,18 @@
 #include "jit/BaselineJIT.h"
 #include "jit/Ion.h"
 #include "vm/ArrayObject.h"
 #include "vm/JSCompartment.h"
 #include "vm/JSObject.h"
 #include "vm/JSScript.h"
 #include "vm/Runtime.h"
 #include "vm/Shape.h"
-#include "vm/StringType.h"
-#include "vm/SymbolType.h"
+#include "vm/String.h"
+#include "vm/Symbol.h"
 #include "vm/WrapperObject.h"
 #include "wasm/WasmInstance.h"
 #include "wasm/WasmJS.h"
 #include "wasm/WasmModule.h"
 
 using mozilla::MallocSizeOf;
 using mozilla::Move;
 using mozilla::PodCopy;
--- a/js/src/vm/NativeObject.h
+++ b/js/src/vm/NativeObject.h
@@ -17,17 +17,17 @@
 
 #include "gc/Barrier.h"
 #include "gc/Heap.h"
 #include "gc/Marking.h"
 #include "js/Value.h"
 #include "vm/JSObject.h"
 #include "vm/Shape.h"
 #include "vm/ShapedObject.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 #include "vm/TypeInference.h"
 
 namespace js {
 
 class Shape;
 class TenuringTracer;
 
 /*
--- a/js/src/vm/NumberObject.h
+++ b/js/src/vm/NumberObject.h
@@ -2,17 +2,17 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef vm_NumberObject_h
 #define vm_NumberObject_h
 
-#include "builtin/Number.h"
+#include "jsnum.h"
 
 namespace js {
 
 class NumberObject : public NativeObject
 {
     /* Stores this Number object's [[PrimitiveValue]]. */
     static const unsigned PRIMITIVE_VALUE_SLOT = 0;
 
--- a/js/src/vm/ObjectGroup.cpp
+++ b/js/src/vm/ObjectGroup.cpp
@@ -3,17 +3,17 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "vm/ObjectGroup.h"
 
 #include "jsexn.h"
 
-#include "builtin/DataView.h"
+#include "builtin/DataViewObject.h"
 #include "gc/FreeOp.h"
 #include "gc/HashUtil.h"
 #include "gc/Policy.h"
 #include "gc/StoreBuffer.h"
 #include "gc/Zone.h"
 #include "js/CharacterEncoding.h"
 #include "vm/ArrayObject.h"
 #include "vm/JSObject.h"
--- a/js/src/vm/RegExpObject.cpp
+++ b/js/src/vm/RegExpObject.cpp
@@ -4,35 +4,34 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "vm/RegExpObject.h"
 
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/PodOperations.h"
 
-#include "builtin/String.h"
+#include "jsstr.h"
 #ifdef DEBUG
 #include "jsutil.h"
 #endif
 
 #include "builtin/RegExp.h"
 #include "frontend/TokenStream.h"
 #include "gc/HashUtil.h"
 #ifdef DEBUG
 #include "irregexp/RegExpBytecode.h"
 #endif
 #include "irregexp/RegExpParser.h"
-#include "util/StringBuffer.h"
 #include "vm/MatchPairs.h"
 #include "vm/RegExpStatics.h"
-#include "vm/StringType.h"
+#include "vm/StringBuffer.h"
 #include "vm/TraceLogging.h"
 #ifdef DEBUG
-#include "util/Unicode.h"
+#include "vm/Unicode.h"
 #endif
 #include "vm/Xdr.h"
 
 #include "vm/JSObject-inl.h"
 #include "vm/NativeObject-inl.h"
 #include "vm/Shape-inl.h"
 
 using namespace js;
--- a/js/src/vm/Runtime.cpp
+++ b/js/src/vm/Runtime.cpp
@@ -17,17 +17,17 @@
 # include <sys/resource.h>
 #endif // defined(XP_DARWIN) || defined(XP_UNIX) || defined(XP_WIN)
 #include <locale.h>
 #include <string.h>
 #ifdef JS_CAN_CHECK_THREADSAFE_ACCESSES
 # include <sys/mman.h>
 #endif
 
-#include "builtin/Math.h"
+#include "jsmath.h"
 
 #include "builtin/Promise.h"
 #include "gc/FreeOp.h"
 #include "gc/GCInternals.h"
 #include "gc/PublicIterators.h"
 #include "jit/arm/Simulator-arm.h"
 #include "jit/arm64/vixl/Simulator-vixl.h"
 #include "jit/JitCompartment.h"
--- a/js/src/vm/Runtime.h
+++ b/js/src/vm/Runtime.h
@@ -16,17 +16,17 @@
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/PodOperations.h"
 #include "mozilla/Scoped.h"
 #include "mozilla/ThreadLocal.h"
 #include "mozilla/Vector.h"
 
 #include <setjmp.h>
 
-#include "builtin/Atomics.h"
+#include "builtin/AtomicsObject.h"
 #include "builtin/intl/SharedIntlData.h"
 #include "builtin/Promise.h"
 #include "frontend/NameCollections.h"
 #include "gc/GCRuntime.h"
 #include "gc/Tracer.h"
 #include "gc/ZoneGroup.h"
 #include "irregexp/RegExpStack.h"
 #include "js/Debug.h"
@@ -44,17 +44,17 @@
 #include "vm/DateTime.h"
 #include "vm/GeckoProfiler.h"
 #include "vm/JSAtom.h"
 #include "vm/JSScript.h"
 #include "vm/Scope.h"
 #include "vm/SharedImmutableStringsCache.h"
 #include "vm/Stack.h"
 #include "vm/Stopwatch.h"
-#include "vm/SymbolType.h"
+#include "vm/Symbol.h"
 #include "wasm/WasmSignalHandlers.h"
 
 #ifdef _MSC_VER
 #pragma warning(push)
 #pragma warning(disable:4100) /* Silence unreferenced formal parameter warnings */
 #endif
 
 namespace js {
@@ -713,17 +713,17 @@ struct JSRuntime : public js::MallocProv
 
   public:
     js::FreeOp* defaultFreeOp() {
         MOZ_ASSERT(defaultFreeOp_);
         return defaultFreeOp_;
     }
 
 #if !EXPOSE_INTL_API
-    /* Number localization, used by builtin/Number.cpp. */
+    /* Number localization, used by jsnum.cpp. */
     js::WriteOnceData<const char*> thousandsSeparator;
     js::WriteOnceData<const char*> decimalSeparator;
     js::WriteOnceData<const char*> numGrouping;
 #endif
 
   private:
     mozilla::Maybe<js::SharedImmutableStringsCache> sharedImmutableStrings_;
 
--- a/js/src/vm/SavedStacks.cpp
+++ b/js/src/vm/SavedStacks.cpp
@@ -11,32 +11,32 @@
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Move.h"
 
 #include <algorithm>
 #include <math.h>
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
+#include "jsmath.h"
+#include "jsnum.h"
 
-#include "builtin/Math.h"
-#include "builtin/Number.h"
 #include "gc/FreeOp.h"
 #include "gc/HashUtil.h"
 #include "gc/Marking.h"
 #include "gc/Policy.h"
 #include "gc/Rooting.h"
 #include "js/CharacterEncoding.h"
 #include "js/Vector.h"
-#include "util/StringBuffer.h"
 #include "vm/Debugger.h"
 #include "vm/GeckoProfiler.h"
 #include "vm/JSCompartment.h"
 #include "vm/JSScript.h"
 #include "vm/SavedFrame.h"
+#include "vm/StringBuffer.h"
 #include "vm/Time.h"
 #include "vm/WrapperObject.h"
 
 #include "vm/GeckoProfiler-inl.h"
 #include "vm/JSContext-inl.h"
 #include "vm/NativeObject-inl.h"
 #include "vm/Stack-inl.h"
 
--- a/js/src/vm/SavedStacks.h
+++ b/js/src/vm/SavedStacks.h
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef vm_SavedStacks_h
 #define vm_SavedStacks_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/FastBernoulliTrial.h"
 
-#include "builtin/Math.h"
+#include "jsmath.h"
 
 #include "js/HashTable.h"
 #include "js/Wrapper.h"
 #include "vm/JSContext.h"
 #include "vm/SavedFrame.h"
 #include "vm/Stack.h"
 
 namespace js {
--- a/js/src/vm/Scope.cpp
+++ b/js/src/vm/Scope.cpp
@@ -4,19 +4,19 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "vm/Scope.h"
 
 #include "builtin/ModuleObject.h"
 #include "gc/Allocator.h"
 #include "gc/FreeOp.h"
-#include "util/StringBuffer.h"
 #include "vm/EnvironmentObject.h"
 #include "vm/JSScript.h"
+#include "vm/StringBuffer.h"
 #include "wasm/WasmInstance.h"
 
 #include "gc/ObjectKind-inl.h"
 #include "vm/Shape-inl.h"
 
 using namespace js;
 
 using mozilla::Maybe;
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -6,59 +6,59 @@
 
 #include "vm/SelfHosting.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Casting.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Maybe.h"
 
+#include "jsarray.h"
+#include "jsdate.h"
 #include "jsfriendapi.h"
+#include "jsstr.h"
 #include "selfhosted.out.h"
 
-#include "builtin/Array.h"
-#include "builtin/Date.h"
 #include "builtin/intl/Collator.h"
 #include "builtin/intl/DateTimeFormat.h"
-#include "builtin/intl/Intl.h"
+#include "builtin/intl/IntlObject.h"
 #include "builtin/intl/NumberFormat.h"
 #include "builtin/intl/PluralRules.h"
 #include "builtin/intl/RelativeTimeFormat.h"
-#include "builtin/Map.h"
+#include "builtin/MapObject.h"
 #include "builtin/ModuleObject.h"
 #include "builtin/Object.h"
 #include "builtin/Promise.h"
 #include "builtin/Reflect.h"
 #include "builtin/RegExp.h"
 #include "builtin/SelfHostingDefines.h"
 #include "builtin/SIMD.h"
 #include "builtin/Stream.h"
-#include "builtin/String.h"
 #include "builtin/TypedObject.h"
-#include "builtin/WeakMap.h"
+#include "builtin/WeakMapObject.h"
 #include "gc/HashUtil.h"
 #include "gc/Marking.h"
 #include "gc/Policy.h"
 #include "jit/AtomicOperations.h"
 #include "jit/InlinableNatives.h"
 #include "js/CharacterEncoding.h"
 #include "js/Date.h"
 #include "js/Wrapper.h"
-#include "util/StringBuffer.h"
 #include "vm/ArgumentsObject.h"
 #include "vm/Compression.h"
 #include "vm/GeneratorObject.h"
 #include "vm/Interpreter.h"
 #include "vm/Iteration.h"
 #include "vm/JSCompartment.h"
 #include "vm/JSContext.h"
 #include "vm/JSFunction.h"
 #include "vm/Printer.h"
 #include "vm/RegExpObject.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
+#include "vm/StringBuffer.h"
 #include "vm/TypedArrayObject.h"
 #include "vm/WrapperObject.h"
 
 #include "gc/PrivateIterators-inl.h"
 #include "vm/BooleanObject-inl.h"
 #include "vm/JSAtom-inl.h"
 #include "vm/JSFunction-inl.h"
 #include "vm/JSObject-inl.h"
--- a/js/src/vm/Shape.cpp
+++ b/js/src/vm/Shape.cpp
@@ -11,17 +11,16 @@
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/PodOperations.h"
 
 #include "gc/FreeOp.h"
 #include "gc/HashUtil.h"
 #include "gc/Policy.h"
 #include "gc/PublicIterators.h"
 #include "js/HashTable.h"
-#include "util/Text.h"
 #include "vm/JSAtom.h"
 #include "vm/JSContext.h"
 #include "vm/JSObject.h"
 
 #include "vm/Caches-inl.h"
 #include "vm/JSCompartment-inl.h"
 #include "vm/JSContext-inl.h"
 #include "vm/JSObject-inl.h"
--- a/js/src/vm/Shape.h
+++ b/js/src/vm/Shape.h
@@ -25,18 +25,18 @@
 #include "gc/Rooting.h"
 #include "js/HashTable.h"
 #include "js/MemoryMetrics.h"
 #include "js/RootingAPI.h"
 #include "js/UbiNode.h"
 #include "vm/JSAtom.h"
 #include "vm/ObjectGroup.h"
 #include "vm/Printer.h"
-#include "vm/StringType.h"
-#include "vm/SymbolType.h"
+#include "vm/String.h"
+#include "vm/Symbol.h"
 
 #ifdef _MSC_VER
 #pragma warning(push)
 #pragma warning(disable:4800)
 #pragma warning(push)
 #pragma warning(disable:4100) /* Silence unreferenced formal parameter warnings */
 #endif
 
--- a/js/src/vm/SharedImmutableStringsCache.cpp
+++ b/js/src/vm/SharedImmutableStringsCache.cpp
@@ -1,18 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "vm/SharedImmutableStringsCache-inl.h"
 
-#include "builtin/String.h"
-#include "util/Text.h"
+#include "jsstr.h"
 
 namespace js {
 
 SharedImmutableString::SharedImmutableString(
     ExclusiveData<SharedImmutableStringsCache::Inner>::Guard& locked,
     SharedImmutableStringsCache::StringBox* box)
   : cache_(locked)
   , box_(box)
--- a/js/src/vm/SharedImmutableStringsCache.h
+++ b/js/src/vm/SharedImmutableStringsCache.h
@@ -8,17 +8,17 @@
 #define vm_SharedImmutableStringsCache_h
 
 #include "mozilla/Maybe.h"
 #include "mozilla/UniquePtr.h"
 
 #include <cstring>
 #include <new> // for placement new
 
-#include "builtin/String.h"
+#include "jsstr.h"
 
 #include "js/HashTable.h"
 #include "js/Utility.h"
 
 #include "threading/ExclusiveData.h"
 
 #include "vm/MutexIDs.h"
 
rename from js/src/vm/StringType-inl.h
rename to js/src/vm/String-inl.h
--- a/js/src/vm/StringType-inl.h
+++ b/js/src/vm/String-inl.h
@@ -1,18 +1,18 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef vm_StringType_inl_h
-#define vm_StringType_inl_h
+#ifndef vm_String_inl_h
+#define vm_String_inl_h
 
-#include "vm/StringType.h"
+#include "vm/String.h"
 
 #include "mozilla/PodOperations.h"
 #include "mozilla/Range.h"
 
 #include "gc/Allocator.h"
 #include "gc/FreeOp.h"
 #include "gc/Marking.h"
 #include "vm/JSCompartment.h"
@@ -423,9 +423,9 @@ JSExternalString::finalize(js::FreeOp* f
         fop->free_(nonInlineCharsRaw());
         return;
     }
 
     const JSStringFinalizer* fin = externalFinalizer();
     fin->finalize(fin, const_cast<char16_t*>(rawTwoByteChars()));
 }
 
-#endif /* vm_StringType_inl_h */
+#endif /* vm_String_inl_h */
rename from js/src/vm/StringType.cpp
rename to js/src/vm/String.cpp
--- a/js/src/vm/StringType.cpp
+++ b/js/src/vm/String.cpp
@@ -1,38 +1,34 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "vm/StringType-inl.h"
+#include "vm/String-inl.h"
 
-#include "mozilla/FloatingPoint.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/PodOperations.h"
 #include "mozilla/RangedPtr.h"
 #include "mozilla/TypeTraits.h"
 #include "mozilla/Unused.h"
 
 #include "gc/Marking.h"
 #include "gc/Nursery.h"
 #include "js/UbiNode.h"
-#include "util/StringBuffer.h"
 #include "vm/GeckoProfiler.h"
 
 #include "vm/GeckoProfiler-inl.h"
 #include "vm/JSCompartment-inl.h"
 #include "vm/JSContext-inl.h"
-#include "vm/JSObject-inl.h"
 
 using namespace js;
 
-using mozilla::IsNegativeZero;
 using mozilla::IsSame;
 using mozilla::PodCopy;
 using mozilla::PodEqual;
 using mozilla::RangedPtr;
 using mozilla::RoundUpPow2;
 using mozilla::Unused;
 
 using JS::AutoCheckCannotGC;
@@ -755,175 +751,16 @@ JSDependentString::dumpRepresentation(js
     if (mozilla::Maybe<size_t> offset = baseOffset())
         out.printf("%*soffset: %zu\n", indent, "", *offset);
 
     out.printf("%*sbase: ", indent, "");
     base()->dumpRepresentation(out, indent);
 }
 #endif
 
-bool
-js::EqualChars(JSLinearString* str1, JSLinearString* str2)
-{
-    MOZ_ASSERT(str1->length() == str2->length());
-
-    size_t len = str1->length();
-
-    AutoCheckCannotGC nogc;
-    if (str1->hasTwoByteChars()) {
-        if (str2->hasTwoByteChars())
-            return PodEqual(str1->twoByteChars(nogc), str2->twoByteChars(nogc), len);
-
-        return EqualChars(str2->latin1Chars(nogc), str1->twoByteChars(nogc), len);
-    }
-
-    if (str2->hasLatin1Chars())
-        return PodEqual(str1->latin1Chars(nogc), str2->latin1Chars(nogc), len);
-
-    return EqualChars(str1->latin1Chars(nogc), str2->twoByteChars(nogc), len);
-}
-
-bool
-js::HasSubstringAt(JSLinearString* text, JSLinearString* pat, size_t start)
-{
-    MOZ_ASSERT(start + pat->length() <= text->length());
-
-    size_t patLen = pat->length();
-
-    AutoCheckCannotGC nogc;
-    if (text->hasLatin1Chars()) {
-        const Latin1Char* textChars = text->latin1Chars(nogc) + start;
-        if (pat->hasLatin1Chars())
-            return PodEqual(textChars, pat->latin1Chars(nogc), patLen);
-
-        return EqualChars(textChars, pat->twoByteChars(nogc), patLen);
-    }
-
-    const char16_t* textChars = text->twoByteChars(nogc) + start;
-    if (pat->hasTwoByteChars())
-        return PodEqual(textChars, pat->twoByteChars(nogc), patLen);
-
-    return EqualChars(pat->latin1Chars(nogc), textChars, patLen);
-}
-
-bool
-js::EqualStrings(JSContext* cx, JSString* str1, JSString* str2, bool* result)
-{
-    if (str1 == str2) {
-        *result = true;
-        return true;
-    }
-
-    size_t length1 = str1->length();
-    if (length1 != str2->length()) {
-        *result = false;
-        return true;
-    }
-
-    JSLinearString* linear1 = str1->ensureLinear(cx);
-    if (!linear1)
-        return false;
-    JSLinearString* linear2 = str2->ensureLinear(cx);
-    if (!linear2)
-        return false;
-
-    *result = EqualChars(linear1, linear2);
-    return true;
-}
-
-bool
-js::EqualStrings(JSLinearString* str1, JSLinearString* str2)
-{
-    if (str1 == str2)
-        return true;
-
-    size_t length1 = str1->length();
-    if (length1 != str2->length())
-        return false;
-
-    return EqualChars(str1, str2);
-}
-
-int32_t
-js::CompareChars(const char16_t* s1, size_t len1, JSLinearString* s2)
-{
-    AutoCheckCannotGC nogc;
-    return s2->hasLatin1Chars()
-           ? CompareChars(s1, len1, s2->latin1Chars(nogc), s2->length())
-           : CompareChars(s1, len1, s2->twoByteChars(nogc), s2->length());
-}
-
-static int32_t
-CompareStringsImpl(JSLinearString* str1, JSLinearString* str2)
-{
-    size_t len1 = str1->length();
-    size_t len2 = str2->length();
-
-    AutoCheckCannotGC nogc;
-    if (str1->hasLatin1Chars()) {
-        const Latin1Char* chars1 = str1->latin1Chars(nogc);
-        return str2->hasLatin1Chars()
-               ? CompareChars(chars1, len1, str2->latin1Chars(nogc), len2)
-               : CompareChars(chars1, len1, str2->twoByteChars(nogc), len2);
-    }
-
-    const char16_t* chars1 = str1->twoByteChars(nogc);
-    return str2->hasLatin1Chars()
-           ? CompareChars(chars1, len1, str2->latin1Chars(nogc), len2)
-           : CompareChars(chars1, len1, str2->twoByteChars(nogc), len2);
-}
-
-bool
-js::CompareStrings(JSContext* cx, JSString* str1, JSString* str2, int32_t* result)
-{
-    MOZ_ASSERT(str1);
-    MOZ_ASSERT(str2);
-
-    if (str1 == str2) {
-        *result = 0;
-        return true;
-    }
-
-    JSLinearString* linear1 = str1->ensureLinear(cx);
-    if (!linear1)
-        return false;
-
-    JSLinearString* linear2 = str2->ensureLinear(cx);
-    if (!linear2)
-        return false;
-
-    *result = CompareStringsImpl(linear1, linear2);
-    return true;
-}
-
-int32_t
-js::CompareAtoms(JSAtom* atom1, JSAtom* atom2)
-{
-    return CompareStringsImpl(atom1, atom2);
-}
-
-bool
-js::StringEqualsAscii(JSLinearString* str, const char* asciiBytes)
-{
-    size_t length = strlen(asciiBytes);
-#ifdef DEBUG
-    for (size_t i = 0; i != length; ++i)
-        MOZ_ASSERT(unsigned(asciiBytes[i]) <= 127);
-#endif
-    if (length != str->length())
-        return false;
-
-    const Latin1Char* latin1 = reinterpret_cast<const Latin1Char*>(asciiBytes);
-
-    AutoCheckCannotGC nogc;
-    return str->hasLatin1Chars()
-           ? PodEqual(latin1, str->latin1Chars(nogc), length)
-           : EqualChars(latin1, str->twoByteChars(nogc), length);
-}
-
 template <typename CharT>
 /* static */ bool
 JSFlatString::isIndexSlow(const CharT* s, size_t length, uint32_t* indexp)
 {
     CharT ch = *s;
 
     if (!JS7_ISDEC(ch))
         return false;
@@ -1890,151 +1727,8 @@ JSString::fillWithRepresentatives(JSCont
                                  CheckLatin1))
     {
         return false;
     }
 
     MOZ_ASSERT(index == 22);
     return true;
 }
-
-
-/*** Conversions *********************************************************************************/
-
-const char*
-js::ValueToPrintable(JSContext* cx, const Value& vArg, JSAutoByteString* bytes, bool asSource)
-{
-    RootedValue v(cx, vArg);
-    JSString* str;
-    if (asSource)
-        str = ValueToSource(cx, v);
-    else
-        str = ToString<CanGC>(cx, v);
-    if (!str)
-        return nullptr;
-    str = QuoteString(cx, str, 0);
-    if (!str)
-        return nullptr;
-    return bytes->encodeLatin1(cx, str);
-}
-
-template <AllowGC allowGC>
-JSString*
-js::ToStringSlow(JSContext* cx, typename MaybeRooted<Value, allowGC>::HandleType arg)
-{
-    /* As with ToObjectSlow, callers must verify that |arg| isn't a string. */
-    MOZ_ASSERT(!arg.isString());
-
-    Value v = arg;
-    if (!v.isPrimitive()) {
-        MOZ_ASSERT(!cx->helperThread());
-        if (!allowGC)
-            return nullptr;
-        RootedValue v2(cx, v);
-        if (!ToPrimitive(cx, JSTYPE_STRING, &v2))
-            return nullptr;
-        v = v2;
-    }
-
-    JSString* str;
-    if (v.isString()) {
-        str = v.toString();
-    } else if (v.isInt32()) {
-        str = Int32ToString<allowGC>(cx, v.toInt32());
-    } else if (v.isDouble()) {
-        str = NumberToString<allowGC>(cx, v.toDouble());
-    } else if (v.isBoolean()) {
-        str = BooleanToString(cx, v.toBoolean());
-    } else if (v.isNull()) {
-        str = cx->names().null;
-    } else if (v.isSymbol()) {
-        MOZ_ASSERT(!cx->helperThread());
-        if (allowGC) {
-            JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
-                                      JSMSG_SYMBOL_TO_STRING);
-        }
-        return nullptr;
-    } else {
-        MOZ_ASSERT(v.isUndefined());
-        str = cx->names().undefined;
-    }
-    return str;
-}
-
-template JSString*
-js::ToStringSlow<CanGC>(JSContext* cx, HandleValue arg);
-
-template JSString*
-js::ToStringSlow<NoGC>(JSContext* cx, const Value& arg);
-
-JS_PUBLIC_API(JSString*)
-js::ToStringSlow(JSContext* cx, HandleValue v)
-{
-    return ToStringSlow<CanGC>(cx, v);
-}
-
-static JSString*
-SymbolToSource(JSContext* cx, Symbol* symbol)
-{
-    RootedString desc(cx, symbol->description());
-    SymbolCode code = symbol->code();
-    if (code != SymbolCode::InSymbolRegistry && code != SymbolCode::UniqueSymbol) {
-        // Well-known symbol.
-        MOZ_ASSERT(uint32_t(code) < JS::WellKnownSymbolLimit);
-        return desc;
-    }
-
-    StringBuffer buf(cx);
-    if (code == SymbolCode::InSymbolRegistry ? !buf.append("Symbol.for(") : !buf.append("Symbol("))
-        return nullptr;
-    if (desc) {
-        desc = StringToSource(cx, desc);
-        if (!desc || !buf.append(desc))
-            return nullptr;
-    }
-    if (!buf.append(')'))
-        return nullptr;
-    return buf.finishString();
-}
-
-JSString*
-js::ValueToSource(JSContext* cx, HandleValue v)
-{
-    if (!CheckRecursionLimit(cx))
-        return nullptr;
-    assertSameCompartment(cx, v);
-
-    if (v.isUndefined())
-        return cx->names().void0;
-    if (v.isString())
-        return StringToSource(cx, v.toString());
-    if (v.isSymbol())
-        return SymbolToSource(cx, v.toSymbol());
-    if (v.isPrimitive()) {
-        /* Special case to preserve negative zero, _contra_ toString. */
-        if (v.isDouble() && IsNegativeZero(v.toDouble())) {
-            static const Latin1Char negativeZero[] = {'-', '0'};
-
-            return NewStringCopyN<CanGC>(cx, negativeZero, mozilla::ArrayLength(negativeZero));
-        }
-        return ToString<CanGC>(cx, v);
-    }
-
-    RootedValue fval(cx);
-    RootedObject obj(cx, &v.toObject());
-    if (!GetProperty(cx, obj, obj, cx->names().toSource, &fval))
-        return nullptr;
-    if (IsCallable(fval)) {
-        RootedValue v(cx);
-        if (!js::Call(cx, fval, obj, &v))
-            return nullptr;
-
-        return ToString<CanGC>(cx, v);
-    }
-
-    return ObjectToSource(cx, obj);
-}
-
-JSString*
-js::StringToSource(JSContext* cx, JSString* str)
-{
-    return QuoteString(cx, str, '"');
-}
rename from js/src/vm/StringType.h
rename to js/src/vm/String.h
--- a/js/src/vm/StringType.h
+++ b/js/src/vm/String.h
@@ -1,33 +1,33 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef vm_StringType_h
-#define vm_StringType_h
+#ifndef vm_String_h
+#define vm_String_h
 
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/PodOperations.h"
 #include "mozilla/Range.h"
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
+#include "jsstr.h"
 
-#include "builtin/String.h"
 #include "gc/Barrier.h"
 #include "gc/Cell.h"
 #include "gc/Heap.h"
 #include "gc/Nursery.h"
 #include "gc/Rooting.h"
 #include "js/CharacterEncoding.h"
 #include "js/RootingAPI.h"
-#include "util/Text.h"
+
 #include "vm/Printer.h"
 
 class JSDependentString;
 class JSExtensibleString;
 class JSExternalString;
 class JSInlineString;
 class JSRope;
 
@@ -1486,147 +1486,16 @@ NewStringCopyUTF8Z(JSContext* cx, const 
 }
 
 JSString*
 NewMaybeExternalString(JSContext* cx, const char16_t* s, size_t n, const JSStringFinalizer* fin,
                        bool* allocatedExternal);
 
 JS_STATIC_ASSERT(sizeof(HashNumber) == 4);
 
-template <AllowGC allowGC>
-extern JSString*
-ConcatStrings(JSContext* cx,
-              typename MaybeRooted<JSString*, allowGC>::HandleType left,
-              typename MaybeRooted<JSString*, allowGC>::HandleType right);
-
-/*
- * Test if strings are equal. The caller can call the function even if str1
- * or str2 are not GC-allocated things.
- */
-extern bool
-EqualStrings(JSContext* cx, JSString* str1, JSString* str2, bool* result);
-
-/* Use the infallible method instead! */
-extern bool
-EqualStrings(JSContext* cx, JSLinearString* str1, JSLinearString* str2, bool* result) = delete;
-
-/* EqualStrings is infallible on linear strings. */
-extern bool
-EqualStrings(JSLinearString* str1, JSLinearString* str2);
-
-/**
- * Compare two strings that are known to be the same length.
- * Exposed for the JITs; for ordinary uses, EqualStrings() is more sensible.
- *
- * Precondition: str1->length() == str2->length().
- */
-extern bool
-EqualChars(JSLinearString* str1, JSLinearString* str2);
-
-/*
- * Return less than, equal to, or greater than zero depending on whether
- * `s1[0..len1]` is less than, equal to, or greater than `s2`.
- */
-extern int32_t
-CompareChars(const char16_t* s1, size_t len1, JSLinearString* s2);
-
-/*
- * Compare two strings, like CompareChars, but store the result in `*result`.
- * This flattens the strings and therefore can fail.
- */
-extern bool
-CompareStrings(JSContext* cx, JSString* str1, JSString* str2, int32_t* result);
-
-/*
- * Same as CompareStrings but for atoms.  Don't use this to just test
- * for equality; use this when you need an ordering on atoms.
- */
-extern int32_t
-CompareAtoms(JSAtom* atom1, JSAtom* atom2);
-
-/*
- * Return true if the string matches the given sequence of ASCII bytes.
- */
-extern bool
-StringEqualsAscii(JSLinearString* str, const char* asciiBytes);
-
-extern int
-StringFindPattern(JSLinearString* text, JSLinearString* pat, size_t start);
-
-/**
- * Return true if the string contains a pattern at |start|.
- *
- * Precondition: `text` is long enough that this might be true;
- * that is, it has at least `start + pat->length()` characters.
- */
-extern bool
-HasSubstringAt(JSLinearString* text, JSLinearString* pat, size_t start);
-
-/*
- * Computes |str|'s substring for the range [beginInt, beginInt + lengthInt).
- * Negative, overlarge, swapped, etc. |beginInt| and |lengthInt| are forbidden
- * and constitute API misuse.
- */
-JSString*
-SubstringKernel(JSContext* cx, HandleString str, int32_t beginInt, int32_t lengthInt);
-
-
-/*** Conversions *********************************************************************************/
-
-/*
- * Convert a value to a printable C string.
- */
-extern const char*
-ValueToPrintable(JSContext* cx, const Value&, JSAutoByteString* bytes, bool asSource = false);
-
-/*
- * Convert a non-string value to a string, returning null after reporting an
- * error, otherwise returning a new string reference.
- */
-template <AllowGC allowGC>
-extern JSString*
-ToStringSlow(JSContext* cx, typename MaybeRooted<Value, allowGC>::HandleType arg);
-
-/*
- * Convert the given value to a string.  This method includes an inline
- * fast-path for the case where the value is already a string; if the value is
- * known not to be a string, use ToStringSlow instead.
- */
-template <AllowGC allowGC>
-static MOZ_ALWAYS_INLINE JSString*
-ToString(JSContext* cx, JS::HandleValue v)
-{
-    if (v.isString())
-        return v.toString();
-    return ToStringSlow<allowGC>(cx, v);
-}
-
-/*
- * This function implements E-262-3 section 9.8, toString. Convert the given
- * value to a string of characters appended to the given buffer. On error, the
- * passed buffer may have partial results appended.
- */
-inline bool
-ValueToStringBuffer(JSContext* cx, const Value& v, StringBuffer& sb);
-
-/*
- * Convert a value to its source expression, returning null after reporting
- * an error, otherwise returning a new string reference.
- */
-extern JSString*
-ValueToSource(JSContext* cx, HandleValue v);
-
-/*
- * Convert a JSString to its source expression; returns null after reporting an
- * error, otherwise returns a new string reference. No Handle needed since the
- * input is dead after the GC.
- */
-extern JSString*
-StringToSource(JSContext* cx, JSString* str);
-
 } /* namespace js */
 
 // Addon IDs are interned atoms which are never destroyed. This detail is
 // not exposed outside the API.
 class JSAddonId : public JSAtom
 {};
 
 MOZ_ALWAYS_INLINE bool
@@ -1837,9 +1706,9 @@ template<>
 inline JSString*
 TenuredCell::as<JSString>() {
     MOZ_ASSERT(is<JSString>());
     return reinterpret_cast<JSString*>(this);
 }
 }
 }
 
-#endif /* vm_StringType_h */
+#endif /* vm_String_h */
rename from js/src/util/StringBuffer.cpp
rename to js/src/vm/StringBuffer.cpp
--- a/js/src/util/StringBuffer.cpp
+++ b/js/src/vm/StringBuffer.cpp
@@ -1,20 +1,20 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "util/StringBuffer.h"
+#include "vm/StringBuffer.h"
 
 #include "mozilla/Range.h"
 
 #include "vm/JSObject-inl.h"
-#include "vm/StringType-inl.h"
+#include "vm/String-inl.h"
 
 using namespace js;
 
 template <typename CharT, class Buffer>
 static CharT*
 ExtractWellSized(JSContext* cx, Buffer& cb)
 {
     size_t capacity = cb.capacity();
rename from js/src/util/StringBuffer.h
rename to js/src/vm/StringBuffer.h
--- a/js/src/util/StringBuffer.h
+++ b/js/src/vm/StringBuffer.h
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef util_StringBuffer_h
-#define util_StringBuffer_h
+#ifndef vm_StringBuffer_h
+#define vm_StringBuffer_h
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/MaybeOneOf.h"
 
 #include "js/Vector.h"
 #include "vm/JSContext.h"
 
 namespace js {
@@ -341,9 +341,9 @@ ValueToStringBuffer(JSContext* cx, const
 inline bool
 BooleanToStringBuffer(bool b, StringBuffer& sb)
 {
     return b ? sb.append("true") : sb.append("false");
 }
 
 }  /* namespace js */
 
-#endif /* util_StringBuffer_h */
+#endif /* vm_StringBuffer_h */
--- a/js/src/vm/StringObject.h
+++ b/js/src/vm/StringObject.h
@@ -2,17 +2,17 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef vm_StringObject_h
 #define vm_StringObject_h
 
-#include "builtin/String.h"
+#include "jsstr.h"
 
 #include "vm/JSObject.h"
 #include "vm/Shape.h"
 
 namespace js {
 
 class StringObject : public NativeObject
 {
--- a/js/src/vm/StructuredClone.cpp
+++ b/js/src/vm/StructuredClone.cpp
@@ -30,20 +30,20 @@
 
 #include "mozilla/CheckedInt.h"
 #include "mozilla/EndianUtils.h"
 #include "mozilla/FloatingPoint.h"
 
 #include <algorithm>
 
 #include "jsapi.h"
-
-#include "builtin/DataView.h"
-#include "builtin/Date.h"
-#include "builtin/Map.h"
+#include "jsdate.h"
+
+#include "builtin/DataViewObject.h"
+#include "builtin/MapObject.h"
 #include "js/Date.h"
 #include "js/GCHashTable.h"
 #include "js/Wrapper.h"
 #include "vm/JSContext.h"
 #include "vm/RegExpObject.h"
 #include "vm/SavedFrame.h"
 #include "vm/SharedArrayObject.h"
 #include "vm/TypedArrayObject.h"
rename from js/src/vm/SymbolType.cpp
rename to js/src/vm/Symbol.cpp
--- a/js/src/vm/SymbolType.cpp
+++ b/js/src/vm/Symbol.cpp
@@ -1,22 +1,22 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "vm/SymbolType.h"
+#include "vm/Symbol.h"
 
-#include "builtin/Symbol.h"
+#include "builtin/SymbolObject.h"
 #include "gc/Allocator.h"
 #include "gc/Rooting.h"
-#include "util/StringBuffer.h"
 #include "vm/JSCompartment.h"
 #include "vm/JSContext.h"
+#include "vm/StringBuffer.h"
 
 #include "vm/JSCompartment-inl.h"
 
 using JS::Symbol;
 using namespace js;
 
 Symbol*
 Symbol::newInternal(JSContext* cx, JS::SymbolCode code, uint32_t hash, JSAtom* description,
rename from js/src/vm/SymbolType.h
rename to js/src/vm/Symbol.h
--- a/js/src/vm/SymbolType.h
+++ b/js/src/vm/Symbol.h
@@ -1,32 +1,32 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef vm_SymbolType_h
-#define vm_SymbolType_h
+#ifndef vm_Symbol_h
+#define vm_Symbol_h
 
 #include "mozilla/Attributes.h"
 
 #include <stdio.h>
 
 #include "jsapi.h"
 
 #include "gc/Barrier.h"
 #include "gc/Tracer.h"
 #include "js/AllocPolicy.h"
 #include "js/GCHashTable.h"
 #include "js/RootingAPI.h"
 #include "js/TypeDecls.h"
 #include "js/Utility.h"
 #include "vm/Printer.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
 
 namespace js {
 class AutoLockForExclusiveAccess;
 } // namespace js
 
 namespace JS {
 
 class Symbol : public js::gc::TenuredCell
@@ -142,9 +142,9 @@ class SymbolRegistry : public GCHashSet<
 };
 
 // ES6 rev 27 (2014 Aug 24) 19.4.3.3
 bool
 SymbolDescriptiveString(JSContext* cx, JS::Symbol* sym, JS::MutableHandleValue result);
 
 } /* namespace js */
 
-#endif /* vm_SymbolType_h */
+#endif /* vm_Symbol_h */
--- a/js/src/vm/TraceLoggingGraph.cpp
+++ b/js/src/vm/TraceLoggingGraph.cpp
@@ -12,22 +12,21 @@
 #else
 #include <unistd.h>
 #endif
 
 #include "mozilla/EndianUtils.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/ScopeExit.h"
 
-#include "builtin/String.h"
+#include "jsstr.h"
 
 #include "js/UniquePtr.h"
 #include "threading/LockGuard.h"
 #include "threading/Thread.h"
-#include "util/Text.h"
 #include "vm/TraceLogging.h"
 
 #ifndef DEFAULT_TRACE_LOG_DIR
 # if defined(_WIN32)
 #  define DEFAULT_TRACE_LOG_DIR "."
 # else
 #  define DEFAULT_TRACE_LOG_DIR "/tmp/"
 # endif
--- a/js/src/vm/TraceLoggingTypes.cpp
+++ b/js/src/vm/TraceLoggingTypes.cpp
@@ -1,18 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "vm/TraceLoggingTypes.h"
 
-#include "vm/StringType.h"
-
 class JSLinearString;
 
 uint32_t
 TLStringToTextId(JSLinearString* str)
 {
 #define NAME(textId) if (js::StringEqualsAscii(str, #textId)) return TraceLogger_ ## textId;
     TRACELOGGER_TREE_ITEMS(NAME)
     TRACELOGGER_LOG_ITEMS(NAME)
--- a/js/src/vm/TraceLoggingTypes.h
+++ b/js/src/vm/TraceLoggingTypes.h
@@ -2,17 +2,17 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef TraceLoggingTypes_h
 #define TraceLoggingTypes_h
 
-#include "builtin/String.h"
+#include "jsstr.h"
 
 #include "js/AllocPolicy.h"
 
 // Tree items, meaning they have a start and stop and form a nested tree.
 #define TRACELOGGER_TREE_ITEMS(_)                     \
     _(AnnotateScripts)                                \
     _(Baseline)                                       \
     _(BaselineCompilation)                            \
--- a/js/src/vm/TypeInference-inl.h
+++ b/js/src/vm/TypeInference-inl.h
@@ -10,17 +10,17 @@
 #define vm_TypeInference_inl_h
 
 #include "vm/TypeInference.h"
 
 #include "mozilla/BinarySearch.h"
 #include "mozilla/Casting.h"
 #include "mozilla/PodOperations.h"
 
-#include "builtin/Symbol.h"
+#include "builtin/SymbolObject.h"
 #include "gc/GC.h"
 #include "jit/BaselineJIT.h"
 #include "vm/ArrayObject.h"
 #include "vm/BooleanObject.h"
 #include "vm/NumberObject.h"
 #include "vm/SharedArrayObject.h"
 #include "vm/StringObject.h"
 #include "vm/TypedArrayObject.h"
--- a/js/src/vm/TypeInference.cpp
+++ b/js/src/vm/TypeInference.cpp
@@ -8,17 +8,17 @@
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/PodOperations.h"
 #include "mozilla/Sprintf.h"
 
 #include "jsapi.h"
-#include "builtin/String.h"
+#include "jsstr.h"
 
 #include "gc/HashUtil.h"
 #include "jit/BaselineJIT.h"
 #include "jit/CompileInfo.h"
 #include "jit/Ion.h"
 #include "jit/IonAnalysis.h"
 #include "jit/JitCompartment.h"
 #include "jit/OptimizationTracking.h"
--- a/js/src/vm/TypedArrayObject-inl.h
+++ b/js/src/vm/TypedArrayObject-inl.h
@@ -10,18 +10,19 @@
 /* Utilities and common inline code for TypedArray */
 
 #include "vm/TypedArrayObject.h"
 
 #include "mozilla/Assertions.h"
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/PodOperations.h"
 
-#include "builtin/Array.h"
-#include "builtin/Number.h"
+#include "jsarray.h"
+#include "jsnum.h"
+
 #include "gc/Zone.h"
 #include "jit/AtomicOperations.h"
 #include "js/Conversions.h"
 #include "js/Value.h"
 #include "vm/JSContext.h"
 #include "vm/NativeObject.h"
 
 #include "gc/ObjectKind-inl.h"
--- a/js/src/vm/TypedArrayObject.cpp
+++ b/js/src/vm/TypedArrayObject.cpp
@@ -13,22 +13,22 @@
 #include "mozilla/PodOperations.h"
 
 #include <string.h>
 #ifndef XP_WIN
 # include <sys/mman.h>
 #endif
 
 #include "jsapi.h"
+#include "jsarray.h"
+#include "jsnum.h"
 #include "jstypes.h"
 #include "jsutil.h"
 
-#include "builtin/Array.h"
-#include "builtin/DataView.h"
-#include "builtin/Number.h"
+#include "builtin/DataViewObject.h"
 #include "builtin/TypedObjectConstants.h"
 #include "gc/Barrier.h"
 #include "gc/Marking.h"
 #include "jit/InlinableNatives.h"
 #include "js/Conversions.h"
 #include "js/Wrapper.h"
 #include "util/Windows.h"
 #include "vm/ArrayBufferObject.h"
--- a/js/src/vm/UbiNode.cpp
+++ b/js/src/vm/UbiNode.cpp
@@ -8,35 +8,34 @@
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Range.h"
 #include "mozilla/Scoped.h"
 
 #include <algorithm>
 
-#include "builtin/String.h"
+#include "jsstr.h"
 
 #include "jit/IonCode.h"
 #include "js/Debug.h"
 #include "js/TracingAPI.h"
 #include "js/TypeDecls.h"
 #include "js/Utility.h"
 #include "js/Vector.h"
-#include "util/Text.h"
 #include "vm/Debugger.h"
 #include "vm/EnvironmentObject.h"
 #include "vm/GlobalObject.h"
 #include "vm/JSContext.h"
 #include "vm/JSObject.h"
 #include "vm/JSScript.h"
 #include "vm/Scope.h"
 #include "vm/Shape.h"
-#include "vm/StringType.h"
-#include "vm/SymbolType.h"
+#include "vm/String.h"
+#include "vm/Symbol.h"
 
 #include "vm/Debugger-inl.h"
 #include "vm/JSObject-inl.h"
 
 using namespace js;
 
 using mozilla::RangedPtr;
 using JS::DispatchTyped;
--- a/js/src/vm/UbiNodeCensus.cpp
+++ b/js/src/vm/UbiNodeCensus.cpp
@@ -1,17 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "js/UbiNodeCensus.h"
 
-#include "util/Text.h"
 #include "vm/JSCompartment.h"
 #include "vm/JSContext.h"
 
 #include "vm/JSObject-inl.h"
 #include "vm/NativeObject-inl.h"
 
 using namespace js;
 
--- a/js/src/vm/UbiNodeShortestPaths.cpp
+++ b/js/src/vm/UbiNodeShortestPaths.cpp
@@ -4,18 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "js/UbiNodeShortestPaths.h"
 
 #include "mozilla/Maybe.h"
 #include "mozilla/Move.h"
 
-#include "builtin/String.h"
-#include "util/Text.h"
+#include "jsstr.h"
 
 namespace JS {
 namespace ubi {
 
 JS_PUBLIC_API(BackEdge::Ptr)
 BackEdge::clone() const
 {
     BackEdge::Ptr clone(js_new<BackEdge>());
rename from js/src/util/Unicode.cpp
rename to js/src/vm/Unicode.cpp
--- a/js/src/util/Unicode.cpp
+++ b/js/src/vm/Unicode.cpp
@@ -1,16 +1,16 @@
 /* Generated by make_unicode.py DO NOT MODIFY */
 /* Unicode version: 10.0.0 */
 
 /*
  * Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/licenses/publicdomain/
  */
-#include "util/Unicode.h"
+#include "vm/Unicode.h"
 
 using namespace js;
 using namespace js::unicode;
 
 /*
  * So how does indexing work?
  * First let's have a look at a char16_t, 16-bits:
  *              [................]
rename from js/src/util/Unicode.h
rename to js/src/vm/Unicode.h
--- a/js/src/util/Unicode.h
+++ b/js/src/vm/Unicode.h
@@ -1,20 +1,19 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef util_Unicode_h
-#define util_Unicode_h
+#ifndef vm_Unicode_h
+#define vm_Unicode_h
 
 #include "jspubtd.h"
-
-#include "util/UnicodeNonBMP.h"
+#include "vm/UnicodeNonBMP.h"
 
 namespace js {
 namespace unicode {
 
 extern const bool js_isidstart[];
 extern const bool js_isident[];
 extern const bool js_isspace[];
 
@@ -597,9 +596,9 @@ UTF16Decode(char16_t lead, char16_t trai
     MOZ_ASSERT(IsTrailSurrogate(trail));
 
     return (lead << 10) + trail + (NonBMPMin - (LeadSurrogateMin << 10) - TrailSurrogateMin);
 }
 
 } /* namespace unicode */
 } /* namespace js */
 
-#endif /* util_Unicode_h */
+#endif /* vm_Unicode_h */
rename from js/src/util/UnicodeData.txt
rename to js/src/vm/UnicodeData.txt
rename from js/src/util/UnicodeNonBMP.h
rename to js/src/vm/UnicodeNonBMP.h
--- a/js/src/util/UnicodeNonBMP.h
+++ b/js/src/vm/UnicodeNonBMP.h
@@ -2,18 +2,18 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* Generated by make_unicode.py DO NOT MODIFY */
 /* Unicode version: 10.0.0 */
 
-#ifndef util_UnicodeNonBMP_h
-#define util_UnicodeNonBMP_h
+#ifndef vm_UnicodeNonBMP_h
+#define vm_UnicodeNonBMP_h
 
 // |macro| receives the following arguments
 //   macro(FROM, TO, LEAD, TRAIL_FROM, TRAIL_TO, DIFF)
 //     FROM:       code point where the range starts
 //     TO:         code point where the range ends
 //     LEAD:       common lead surrogate of FROM and TO
 //     TRAIL_FROM: trail surrogate of FROM
 //     TRAIL_FROM: trail surrogate of TO
@@ -63,9 +63,9 @@
 // U+1E922 ADLAM SMALL LETTER ALIF .. U+1E943 ADLAM SMALL LETTER SHA
 #define FOR_EACH_NON_BMP_REV_CASE_FOLDING(macro) \
     macro(0x10428, 0x1044f, 0xd801, 0xdc28, 0xdc4f, -40) \
     macro(0x104d8, 0x104fb, 0xd801, 0xdcd8, 0xdcfb, -40) \
     macro(0x10cc0, 0x10cf2, 0xd803, 0xdcc0, 0xdcf2, -64) \
     macro(0x118c0, 0x118df, 0xd806, 0xdcc0, 0xdcdf, -32) \
     macro(0x1e922, 0x1e943, 0xd83a, 0xdd22, 0xdd43, -34)
 
-#endif /* util_UnicodeNonBMP_h */
+#endif /* vm_UnicodeNonBMP_h */
rename from js/src/util/make_unicode.py
rename to js/src/vm/make_unicode.py
--- a/js/src/wasm/AsmJS.cpp
+++ b/js/src/wasm/AsmJS.cpp
@@ -18,31 +18,30 @@
 
 #include "wasm/AsmJS.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/Compression.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/Unused.h"
 
+#include "jsmath.h"
+#include "jsstr.h"
 #include "jsutil.h"
 
-#include "builtin/Math.h"
 #include "builtin/SIMD.h"
-#include "builtin/String.h"
 #include "frontend/Parser.h"
 #include "gc/Policy.h"
 #include "jit/AtomicOperations.h"
 #include "js/MemoryMetrics.h"
 #include "js/Printf.h"
 #include "js/Wrapper.h"
-#include "util/StringBuffer.h"
-#include "util/Text.h"
 #include "vm/ErrorReporting.h"
 #include "vm/SelfHosting.h"
+#include "vm/StringBuffer.h"
 #include "vm/Time.h"
 #include "vm/TypedArrayObject.h"
 #include "wasm/WasmCompile.h"
 #include "wasm/WasmGenerator.h"
 #include "wasm/WasmInstance.h"
 #include "wasm/WasmIonCompile.h"
 #include "wasm/WasmJS.h"
 #include "wasm/WasmSerialize.h"
--- a/js/src/wasm/WasmBinaryToText.cpp
+++ b/js/src/wasm/WasmBinaryToText.cpp
@@ -13,19 +13,20 @@
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 #include "wasm/WasmBinaryToText.h"
 
-#include "builtin/Number.h"
-#include "util/StringBuffer.h"
+#include "jsnum.h"
+
 #include "vm/ArrayBufferObject.h"
+#include "vm/StringBuffer.h"
 #include "wasm/WasmAST.h"
 #include "wasm/WasmBinaryToAST.h"
 #include "wasm/WasmDebug.h"
 #include "wasm/WasmTextUtils.h"
 #include "wasm/WasmTypes.h"
 
 using namespace js;
 using namespace js::wasm;
--- a/js/src/wasm/WasmBuiltins.cpp
+++ b/js/src/wasm/WasmBuiltins.cpp
@@ -16,22 +16,22 @@
  * limitations under the License.
  */
 
 #include "wasm/WasmBuiltins.h"
 
 #include "mozilla/Atomics.h"
 
 #include "fdlibm.h"
+#include "jslibmath.h"
 
 #include "jit/AtomicOperations.h"
 #include "jit/InlinableNatives.h"
 #include "jit/MacroAssembler.h"
 #include "threading/Mutex.h"
-#include "util/PortableMath.h"
 #include "wasm/WasmInstance.h"
 #include "wasm/WasmStubs.h"
 
 #include "vm/Debugger-inl.h"
 #include "vm/Stack-inl.h"
 
 using namespace js;
 using namespace jit;
--- a/js/src/wasm/WasmCompile.cpp
+++ b/js/src/wasm/WasmCompile.cpp
@@ -17,17 +17,16 @@
  */
 
 #include "wasm/WasmCompile.h"
 
 #include "mozilla/Maybe.h"
 #include "mozilla/Unused.h"
 
 #include "jit/ProcessExecutableMemory.h"
-#include "util/Text.h"
 #include "wasm/WasmBaselineCompile.h"
 #include "wasm/WasmBinaryIterator.h"
 #include "wasm/WasmGenerator.h"
 #include "wasm/WasmIonCompile.h"
 #include "wasm/WasmSignalHandlers.h"
 #include "wasm/WasmValidate.h"
 
 using namespace js;
--- a/js/src/wasm/WasmDebug.cpp
+++ b/js/src/wasm/WasmDebug.cpp
@@ -19,19 +19,18 @@
 #include "wasm/WasmDebug.h"
 
 #include "mozilla/BinarySearch.h"
 
 #include "ds/Sort.h"
 #include "gc/FreeOp.h"
 #include "jit/ExecutableAllocator.h"
 #include "jit/MacroAssembler.h"
-#include "util/StringBuffer.h"
-#include "util/Text.h"
 #include "vm/Debugger.h"
+#include "vm/StringBuffer.h"
 #include "wasm/WasmBinaryToText.h"
 #include "wasm/WasmInstance.h"
 #include "wasm/WasmValidate.h"
 
 using namespace js;
 using namespace js::jit;
 using namespace js::wasm;
 
--- a/js/src/wasm/WasmGenerator.cpp
+++ b/js/src/wasm/WasmGenerator.cpp
@@ -19,17 +19,16 @@
 #include "wasm/WasmGenerator.h"
 
 #include "mozilla/CheckedInt.h"
 #include "mozilla/EnumeratedRange.h"
 #include "mozilla/SHA1.h"
 
 #include <algorithm>
 
-#include "util/Text.h"
 #include "wasm/WasmBaselineCompile.h"
 #include "wasm/WasmCompile.h"
 #include "wasm/WasmIonCompile.h"
 #include "wasm/WasmStubs.h"
 
 #include "jit/MacroAssembler-inl.h"
 
 using namespace js;
--- a/js/src/wasm/WasmJS.cpp
+++ b/js/src/wasm/WasmJS.cpp
@@ -23,20 +23,19 @@
 #include "mozilla/Maybe.h"
 #include "mozilla/RangedPtr.h"
 
 #include "builtin/Promise.h"
 #include "gc/FreeOp.h"
 #include "jit/AtomicOperations.h"
 #include "jit/JitOptions.h"
 #include "js/Printf.h"
-#include "util/StringBuffer.h"
-#include "util/Text.h"
 #include "vm/Interpreter.h"
-#include "vm/StringType.h"
+#include "vm/String.h"
+#include "vm/StringBuffer.h"
 #include "wasm/WasmBaselineCompile.h"
 #include "wasm/WasmCompile.h"
 #include "wasm/WasmInstance.h"
 #include "wasm/WasmIonCompile.h"
 #include "wasm/WasmModule.h"
 #include "wasm/WasmSignalHandlers.h"
 #include "wasm/WasmStubs.h"
 #include "wasm/WasmValidate.h"
--- a/js/src/wasm/WasmTextToBinary.cpp
+++ b/js/src/wasm/WasmTextToBinary.cpp
@@ -17,18 +17,19 @@
  */
 
 #include "wasm/WasmTextToBinary.h"
 
 #include "mozilla/CheckedInt.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/Maybe.h"
 
-#include "builtin/Number.h"
-#include "builtin/String.h"
+#include "jsnum.h"
+#include "jsstr.h"
+
 #include "ds/LifoAlloc.h"
 #include "js/CharacterEncoding.h"
 #include "js/HashTable.h"
 #include "js/Printf.h"
 #include "util/DoubleToString.h"
 #include "wasm/WasmAST.h"
 #include "wasm/WasmTypes.h"
 #include "wasm/WasmValidate.h"
--- a/js/src/wasm/WasmTextUtils.cpp
+++ b/js/src/wasm/WasmTextUtils.cpp
@@ -13,17 +13,17 @@
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 #include "wasm/WasmTextUtils.h"
 
-#include "util/StringBuffer.h"
+#include "vm/StringBuffer.h"
 #include "wasm/WasmTypes.h"
 
 using namespace js;
 using namespace jit;
 using namespace wasm;
 
 using mozilla::IsNaN;
 
--- a/js/src/wasm/WasmTextUtils.h
+++ b/js/src/wasm/WasmTextUtils.h
@@ -16,17 +16,17 @@
  * limitations under the License.
  */
 
 #ifndef wasm_text_utils
 #define wasm_text_utils
 
 #include "NamespaceImports.h"
 
-#include "util/StringBuffer.h"
+#include "vm/StringBuffer.h"
 
 namespace js {
 namespace wasm {
 
 template<size_t base>
 MOZ_MUST_USE bool
 RenderInBase(StringBuffer& sb, uint64_t num);