From 6c5695fa2249a52945f10004501cf524a43a573e Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Fri, 17 Apr 2020 05:38:03 +0000 Subject: [PATCH] Bug 1630346 - Move PlainObject to vm/PlainObject{,-inl}.h. r=jandem Differential Revision: https://phabricator.services.mozilla.com/D71111 --- js/src/builtin/Array.cpp | 1 + js/src/builtin/FinalizationRegistryObject.cpp | 1 + js/src/builtin/JSON.cpp | 1 + js/src/builtin/ModuleObject.cpp | 1 + js/src/builtin/Object.cpp | 1 + js/src/builtin/Object.h | 4 +- js/src/builtin/Promise.cpp | 1 + js/src/builtin/ReflectParse.cpp | 1 + js/src/builtin/Stream.cpp | 1 + js/src/builtin/Symbol.cpp | 1 + js/src/builtin/TestingFunctions.cpp | 1 + js/src/builtin/TypedObject.cpp | 1 + js/src/builtin/intl/Collator.cpp | 1 + js/src/builtin/intl/DateTimeFormat.cpp | 1 + js/src/builtin/intl/IntlObject.cpp | 1 + js/src/builtin/intl/ListFormat.cpp | 1 + js/src/builtin/intl/Locale.cpp | 1 + js/src/builtin/intl/NumberFormat.cpp | 1 + js/src/builtin/intl/PluralRules.cpp | 1 + js/src/builtin/intl/RelativeTimeFormat.cpp | 1 + js/src/builtin/streams/ReadableStream.cpp | 2 +- .../ReadableStreamDefaultController.cpp | 1 + .../streams/ReadableStreamInternals.cpp | 1 + .../builtin/streams/ReadableStreamReader.cpp | 1 + js/src/builtin/streams/StreamAPI.cpp | 2 +- js/src/builtin/streams/WritableStream.cpp | 2 +- js/src/debugger/Debugger.cpp | 1 + js/src/debugger/DebuggerMemory.cpp | 1 + js/src/debugger/Object.cpp | 1 + js/src/debugger/Script.cpp | 1 + js/src/gc/Marking.cpp | 1 + js/src/jit/BaselineCodeGen.cpp | 5 +- js/src/jit/CacheIR.cpp | 3 +- js/src/jit/CodeGenerator.cpp | 3 +- js/src/jit/IonAnalysis.cpp | 1 + js/src/jit/IonAnalysis.h | 5 +- js/src/jit/IonBuilder.cpp | 1 + js/src/jit/MCallOptimize.cpp | 1 + js/src/jit/MIR.cpp | 1 + js/src/jit/Recover.cpp | 1 + js/src/jit/TemplateObject-inl.h | 1 + js/src/jit/VMFunctions.cpp | 1 + js/src/jit/VMFunctions.h | 1 + js/src/jsapi.cpp | 1 + js/src/jsfriendapi.cpp | 1 + js/src/proxy/ScriptedProxyHandler.cpp | 1 + js/src/vm/AsyncIteration.cpp | 1 + js/src/vm/GeneratorObject.cpp | 1 + js/src/vm/GlobalObject.h | 1 + js/src/vm/Interpreter.cpp | 4 +- js/src/vm/Interpreter.h | 3 +- js/src/vm/Iteration.cpp | 1 + js/src/vm/JSContext.cpp | 1 + js/src/vm/JSFunction.cpp | 1 + js/src/vm/JSObject.cpp | 1 + js/src/vm/JSScript.cpp | 1 + js/src/vm/NativeObject-inl.h | 51 ------------- js/src/vm/NativeObject.cpp | 3 +- js/src/vm/NativeObject.h | 19 ----- js/src/vm/ObjectGroup.cpp | 1 + js/src/vm/ObjectGroup.h | 1 + js/src/vm/PlainObject-inl.h | 76 +++++++++++++++++++ js/src/vm/PlainObject.h | 41 ++++++++++ js/src/vm/Realm.h | 1 + js/src/vm/SelfHosting.cpp | 1 + js/src/vm/StructuredClone.cpp | 1 + js/src/vm/TypeInference-inl.h | 1 + js/src/vm/TypeInference.cpp | 1 + js/src/vm/TypeInference.h | 1 + js/src/vm/UbiNodeCensus.cpp | 1 + js/src/wasm/WasmInstance.cpp | 1 + js/src/wasm/WasmJS.cpp | 1 + js/src/wasm/WasmModule.cpp | 1 + 73 files changed, 200 insertions(+), 81 deletions(-) create mode 100644 js/src/vm/PlainObject-inl.h create mode 100644 js/src/vm/PlainObject.h diff --git a/js/src/builtin/Array.cpp b/js/src/builtin/Array.cpp index 446984e35065..1d772342c848 100644 --- a/js/src/builtin/Array.cpp +++ b/js/src/builtin/Array.cpp @@ -36,6 +36,7 @@ #include "vm/JSContext.h" #include "vm/JSFunction.h" #include "vm/JSObject.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/SelfHosting.h" #include "vm/Shape.h" #include "vm/ToSource.h" // js::ValueToSource diff --git a/js/src/builtin/FinalizationRegistryObject.cpp b/js/src/builtin/FinalizationRegistryObject.cpp index ba00742a3eb4..17a326f3ff75 100644 --- a/js/src/builtin/FinalizationRegistryObject.cpp +++ b/js/src/builtin/FinalizationRegistryObject.cpp @@ -12,6 +12,7 @@ #include "gc/Zone.h" #include "vm/GlobalObject.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/JSObject-inl.h" #include "vm/NativeObject-inl.h" diff --git a/js/src/builtin/JSON.cpp b/js/src/builtin/JSON.cpp index 43ba2346317c..5c69d0d4effd 100644 --- a/js/src/builtin/JSON.cpp +++ b/js/src/builtin/JSON.cpp @@ -26,6 +26,7 @@ #include "vm/JSContext.h" #include "vm/JSObject.h" #include "vm/JSONParser.h" +#include "vm/PlainObject.h" // js::PlainObject #include "builtin/Array-inl.h" #include "builtin/Boolean-inl.h" diff --git a/js/src/builtin/ModuleObject.cpp b/js/src/builtin/ModuleObject.cpp index 0b7442b02279..2af12d594171 100644 --- a/js/src/builtin/ModuleObject.cpp +++ b/js/src/builtin/ModuleObject.cpp @@ -23,6 +23,7 @@ #include "vm/AsyncIteration.h" #include "vm/EqualityOperations.h" // js::SameValue #include "vm/ModuleBuilder.h" // js::ModuleBuilder +#include "vm/PlainObject.h" // js::PlainObject #include "vm/PromiseObject.h" // js::PromiseObject #include "vm/SelfHosting.h" diff --git a/js/src/builtin/Object.cpp b/js/src/builtin/Object.cpp index 7e1c310951a5..4f30b6731be1 100644 --- a/js/src/builtin/Object.cpp +++ b/js/src/builtin/Object.cpp @@ -26,6 +26,7 @@ #include "vm/EqualityOperations.h" // js::SameValue #include "vm/ErrorObject.h" #include "vm/JSContext.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/RegExpObject.h" #include "vm/ToSource.h" // js::ValueToSource diff --git a/js/src/builtin/Object.h b/js/src/builtin/Object.h index 212a8b2e383e..5b0f2e99552a 100644 --- a/js/src/builtin/Object.h +++ b/js/src/builtin/Object.h @@ -14,6 +14,8 @@ namespace js { +class PlainObject; + // Object constructor native. Exposed only so the JIT can know its address. MOZ_MUST_USE bool obj_construct(JSContext* cx, unsigned argc, JS::Value* vp); @@ -22,7 +24,7 @@ PlainObject* ObjectCreateImpl(JSContext* cx, HandleObject proto, HandleObjectGroup group = nullptr); PlainObject* ObjectCreateWithTemplate(JSContext* cx, - HandlePlainObject templateObj); + Handle templateObj); // Object methods exposed so they can be installed in the self-hosting global. MOZ_MUST_USE bool obj_propertyIsEnumerable(JSContext* cx, unsigned argc, diff --git a/js/src/builtin/Promise.cpp b/js/src/builtin/Promise.cpp index feb3f0a0df2c..399c77894ab6 100644 --- a/js/src/builtin/Promise.cpp +++ b/js/src/builtin/Promise.cpp @@ -25,6 +25,7 @@ #include "vm/Iteration.h" #include "vm/JSContext.h" #include "vm/JSObject.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/PromiseLookup.h" // js::PromiseLookup #include "vm/PromiseObject.h" // js::PromiseObject, js::PromiseSlot_* #include "vm/SelfHosting.h" diff --git a/js/src/builtin/ReflectParse.cpp b/js/src/builtin/ReflectParse.cpp index 90b949b781b1..405887c9cdcf 100644 --- a/js/src/builtin/ReflectParse.cpp +++ b/js/src/builtin/ReflectParse.cpp @@ -26,6 +26,7 @@ #include "vm/JSAtom.h" #include "vm/JSObject.h" #include "vm/ModuleBuilder.h" // js::ModuleBuilder +#include "vm/PlainObject.h" // js::PlainObject #include "vm/RegExpObject.h" #include "vm/JSObject-inl.h" diff --git a/js/src/builtin/Stream.cpp b/js/src/builtin/Stream.cpp index c4a792f07c0b..b4c700ea1322 100644 --- a/js/src/builtin/Stream.cpp +++ b/js/src/builtin/Stream.cpp @@ -23,6 +23,7 @@ #include "js/PropertySpec.h" #include "vm/Interpreter.h" #include "vm/JSContext.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/PromiseObject.h" // js::PromiseObject, js::PromiseResolvedWithUndefined #include "vm/SelfHosting.h" diff --git a/js/src/builtin/Symbol.cpp b/js/src/builtin/Symbol.cpp index b7aab9e0b343..3b14aae2593b 100644 --- a/js/src/builtin/Symbol.cpp +++ b/js/src/builtin/Symbol.cpp @@ -9,6 +9,7 @@ #include "js/Symbol.h" #include "js/PropertySpec.h" #include "util/StringBuffer.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/SymbolType.h" #include "vm/JSObject-inl.h" diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 3d95304bb6f1..e37698571fa5 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -79,6 +79,7 @@ #include "vm/Iteration.h" #include "vm/JSContext.h" #include "vm/JSObject.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/PromiseObject.h" // js::PromiseObject, js::PromiseSlot_* #include "vm/ProxyObject.h" #include "vm/SavedStacks.h" diff --git a/js/src/builtin/TypedObject.cpp b/js/src/builtin/TypedObject.cpp index 94264c9083b8..6cca6d048ea8 100644 --- a/js/src/builtin/TypedObject.cpp +++ b/js/src/builtin/TypedObject.cpp @@ -19,6 +19,7 @@ #include "vm/GlobalObject.h" #include "vm/JSFunction.h" #include "vm/JSObject.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/Realm.h" #include "vm/SelfHosting.h" #include "vm/StringType.h" diff --git a/js/src/builtin/intl/Collator.cpp b/js/src/builtin/intl/Collator.cpp index 0dce9b934c0e..012dbe5ea555 100644 --- a/js/src/builtin/intl/Collator.cpp +++ b/js/src/builtin/intl/Collator.cpp @@ -29,6 +29,7 @@ #include "unicode/utypes.h" #include "vm/GlobalObject.h" #include "vm/JSContext.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/Runtime.h" #include "vm/StringType.h" diff --git a/js/src/builtin/intl/DateTimeFormat.cpp b/js/src/builtin/intl/DateTimeFormat.cpp index 93608e3df2c3..4cd736534f05 100644 --- a/js/src/builtin/intl/DateTimeFormat.cpp +++ b/js/src/builtin/intl/DateTimeFormat.cpp @@ -34,6 +34,7 @@ #include "vm/DateTime.h" #include "vm/GlobalObject.h" #include "vm/JSContext.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/Runtime.h" #include "vm/JSObject-inl.h" diff --git a/js/src/builtin/intl/IntlObject.cpp b/js/src/builtin/intl/IntlObject.cpp index abb441d6358b..c4a887b06592 100644 --- a/js/src/builtin/intl/IntlObject.cpp +++ b/js/src/builtin/intl/IntlObject.cpp @@ -41,6 +41,7 @@ #include "vm/JSAtom.h" #include "vm/JSContext.h" #include "vm/JSObject.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/StringType.h" #include "vm/JSObject-inl.h" diff --git a/js/src/builtin/intl/ListFormat.cpp b/js/src/builtin/intl/ListFormat.cpp index fdc564dceebc..516cdfaeaa51 100644 --- a/js/src/builtin/intl/ListFormat.cpp +++ b/js/src/builtin/intl/ListFormat.cpp @@ -26,6 +26,7 @@ #include "unicode/ulistformatter.h" #include "unicode/utypes.h" #include "vm/JSContext.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/Runtime.h" // js::ReportAllocationOverflow #include "vm/SelfHosting.h" #include "vm/StringType.h" diff --git a/js/src/builtin/intl/Locale.cpp b/js/src/builtin/intl/Locale.cpp index d02c049e2bf5..d645206a3d74 100644 --- a/js/src/builtin/intl/Locale.cpp +++ b/js/src/builtin/intl/Locale.cpp @@ -34,6 +34,7 @@ #include "util/StringBuffer.h" #include "vm/GlobalObject.h" #include "vm/JSContext.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/Printer.h" #include "vm/StringType.h" diff --git a/js/src/builtin/intl/NumberFormat.cpp b/js/src/builtin/intl/NumberFormat.cpp index 144f0213889c..08b13b2d2b67 100644 --- a/js/src/builtin/intl/NumberFormat.cpp +++ b/js/src/builtin/intl/NumberFormat.cpp @@ -45,6 +45,7 @@ #include "vm/BigIntType.h" #include "vm/GlobalObject.h" #include "vm/JSContext.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/SelfHosting.h" #include "vm/Stack.h" #include "vm/StringType.h" diff --git a/js/src/builtin/intl/PluralRules.cpp b/js/src/builtin/intl/PluralRules.cpp index 02d3363f4345..a0bcf5b6fc75 100644 --- a/js/src/builtin/intl/PluralRules.cpp +++ b/js/src/builtin/intl/PluralRules.cpp @@ -25,6 +25,7 @@ #include "unicode/utypes.h" #include "vm/GlobalObject.h" #include "vm/JSContext.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/StringType.h" #include "vm/JSObject-inl.h" diff --git a/js/src/builtin/intl/RelativeTimeFormat.cpp b/js/src/builtin/intl/RelativeTimeFormat.cpp index a3af58a7692f..513b6a97465d 100644 --- a/js/src/builtin/intl/RelativeTimeFormat.cpp +++ b/js/src/builtin/intl/RelativeTimeFormat.cpp @@ -23,6 +23,7 @@ #include "unicode/utypes.h" #include "vm/GlobalObject.h" #include "vm/JSContext.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/Printer.h" #include "vm/StringType.h" diff --git a/js/src/builtin/streams/ReadableStream.cpp b/js/src/builtin/streams/ReadableStream.cpp index e92e93fb0405..c4e45647442b 100644 --- a/js/src/builtin/streams/ReadableStream.cpp +++ b/js/src/builtin/streams/ReadableStream.cpp @@ -32,8 +32,8 @@ #include "js/Value.h" // JS::Value #include "vm/JSContext.h" // JSContext #include "vm/JSObject.h" // js::GetPrototypeFromBuiltinConstructor -#include "vm/NativeObject.h" // js::PlainObject #include "vm/ObjectOperations.h" // js::GetProperty +#include "vm/PlainObject.h" // js::PlainObject #include "vm/Runtime.h" // JSAtomState #include "vm/StringType.h" // js::EqualStrings, js::ToString diff --git a/js/src/builtin/streams/ReadableStreamDefaultController.cpp b/js/src/builtin/streams/ReadableStreamDefaultController.cpp index 638d3eb3df1f..01730cf150a9 100644 --- a/js/src/builtin/streams/ReadableStreamDefaultController.cpp +++ b/js/src/builtin/streams/ReadableStreamDefaultController.cpp @@ -29,6 +29,7 @@ #include "js/PropertySpec.h" #include "vm/Interpreter.h" #include "vm/JSContext.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/PromiseObject.h" // js::PromiseObject, js::PromiseResolvedWithUndefined #include "vm/SelfHosting.h" diff --git a/js/src/builtin/streams/ReadableStreamInternals.cpp b/js/src/builtin/streams/ReadableStreamInternals.cpp index e015fa87086f..d1b371c5f487 100644 --- a/js/src/builtin/streams/ReadableStreamInternals.cpp +++ b/js/src/builtin/streams/ReadableStreamInternals.cpp @@ -39,6 +39,7 @@ #include "vm/Compartment-inl.h" // JS::Compartment::wrap #include "vm/JSContext-inl.h" // JSContext::check #include "vm/List-inl.h" // js::ListObject, js::AppendToListInFixedSlot, js::StoreNewListInFixedSlot +#include "vm/PlainObject-inl.h" // js::PlainObject::createWithTemplate #include "vm/Realm-inl.h" // JS::Realm using JS::BooleanValue; diff --git a/js/src/builtin/streams/ReadableStreamReader.cpp b/js/src/builtin/streams/ReadableStreamReader.cpp index 1a9f23d76ce9..4ba1336a9b29 100644 --- a/js/src/builtin/streams/ReadableStreamReader.cpp +++ b/js/src/builtin/streams/ReadableStreamReader.cpp @@ -21,6 +21,7 @@ #include "js/Value.h" // JS::Value, JS::UndefinedHandleValue #include "vm/Interpreter.h" // js::GetAndClearException #include "vm/JSContext.h" // JSContext +#include "vm/PlainObject.h" // js::PlainObject #include "vm/PromiseObject.h" // js::PromiseObject, js::PromiseResolvedWithUndefined #include "vm/Runtime.h" // JSRuntime diff --git a/js/src/builtin/streams/StreamAPI.cpp b/js/src/builtin/streams/StreamAPI.cpp index a039ade817b8..71731d10d9d1 100644 --- a/js/src/builtin/streams/StreamAPI.cpp +++ b/js/src/builtin/streams/StreamAPI.cpp @@ -31,7 +31,7 @@ #include "vm/ArrayBufferViewObject.h" // js::ArrayBufferViewObject #include "vm/JSContext.h" // JSContext, CHECK_THREAD #include "vm/JSObject.h" // JSObject -#include "vm/NativeObject.h" // js::PlainObject +#include "vm/PlainObject.h" // js::PlainObject #include "vm/PromiseObject.h" // js::PromiseObject #include "builtin/streams/ReadableStreamReader-inl.h" // js::UnwrapStreamFromReader diff --git a/js/src/builtin/streams/WritableStream.cpp b/js/src/builtin/streams/WritableStream.cpp index 7baf240322fe..1bf38bee8c51 100644 --- a/js/src/builtin/streams/WritableStream.cpp +++ b/js/src/builtin/streams/WritableStream.cpp @@ -27,8 +27,8 @@ #include "js/Value.h" // JS::{,Object}Value #include "vm/JSContext.h" // JSContext #include "vm/JSObject.h" // js::GetPrototypeFromBuiltinConstructor -#include "vm/NativeObject.h" // js::PlainObject #include "vm/ObjectOperations.h" // js::GetProperty +#include "vm/PlainObject.h" // js::PlainObject #include "vm/Realm.h" // JS::Realm #include "vm/Compartment-inl.h" // js::UnwrapAndTypeCheckThis diff --git a/js/src/debugger/Debugger.cpp b/js/src/debugger/Debugger.cpp index 027360aa7c45..48d80ac98a7b 100644 --- a/js/src/debugger/Debugger.cpp +++ b/js/src/debugger/Debugger.cpp @@ -92,6 +92,7 @@ #include "vm/JSObject.h" // for JSObject, RequireObject #include "vm/ObjectGroup.h" // for TenuredObject #include "vm/ObjectOperations.h" // for DefineDataProperty +#include "vm/PlainObject.h" // for js::PlainObject #include "vm/PromiseObject.h" // for js::PromiseObject #include "vm/ProxyObject.h" // for ProxyObject, JSObject::is #include "vm/Realm.h" // for AutoRealm, Realm diff --git a/js/src/debugger/DebuggerMemory.cpp b/js/src/debugger/DebuggerMemory.cpp index 82f889b2d791..9c339724f40b 100644 --- a/js/src/debugger/DebuggerMemory.cpp +++ b/js/src/debugger/DebuggerMemory.cpp @@ -24,6 +24,7 @@ #include "js/Utility.h" #include "vm/GlobalObject.h" #include "vm/JSContext.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/Realm.h" #include "vm/SavedStacks.h" diff --git a/js/src/debugger/Object.cpp b/js/src/debugger/Object.cpp index ca88ce8f2e2c..c99285b5d7d4 100644 --- a/js/src/debugger/Object.cpp +++ b/js/src/debugger/Object.cpp @@ -55,6 +55,7 @@ #include "vm/NativeObject.h" // for NativeObject, JSObject::is #include "vm/ObjectGroup.h" // for GenericObject, NewObjectKind #include "vm/ObjectOperations.h" // for DefineProperty +#include "vm/PlainObject.h" // for js::PlainObject #include "vm/PromiseObject.h" // for js::PromiseObject #include "vm/Realm.h" // for AutoRealm, ErrorCopier, Realm #include "vm/Runtime.h" // for JSAtomState diff --git a/js/src/debugger/Script.cpp b/js/src/debugger/Script.cpp index ad4f8710dde4..c7b9ef4c112c 100644 --- a/js/src/debugger/Script.cpp +++ b/js/src/debugger/Script.cpp @@ -37,6 +37,7 @@ #include "vm/JSFunction.h" // for JSFunction #include "vm/JSObject.h" // for RequireObject, JSObject #include "vm/ObjectOperations.h" // for DefineDataProperty, HasOwnProperty +#include "vm/PlainObject.h" // for js::PlainObject #include "vm/Realm.h" // for AutoRealm #include "vm/Runtime.h" // for JSAtomState, JSRuntime #include "vm/StringType.h" // for NameToId, PropertyName, JSAtom diff --git a/js/src/gc/Marking.cpp b/js/src/gc/Marking.cpp index 0148000b75ae..359ea09ae168 100644 --- a/js/src/gc/Marking.cpp +++ b/js/src/gc/Marking.cpp @@ -49,6 +49,7 @@ #include "gc/Zone-inl.h" #include "vm/GeckoProfiler-inl.h" #include "vm/NativeObject-inl.h" +#include "vm/PlainObject-inl.h" // js::PlainObject #include "vm/Realm-inl.h" #include "vm/StringType-inl.h" diff --git a/js/src/jit/BaselineCodeGen.cpp b/js/src/jit/BaselineCodeGen.cpp index 9ea34db75873..cf4fd096bb4b 100644 --- a/js/src/jit/BaselineCodeGen.cpp +++ b/js/src/jit/BaselineCodeGen.cpp @@ -50,6 +50,9 @@ using mozilla::AssertedCast; using mozilla::Maybe; namespace js { + +class PlainObject; + namespace jit { BaselineCompilerHandler::BaselineCompilerHandler(JSContext* cx, @@ -6390,7 +6393,7 @@ bool BaselineCodeGen::emit_ObjWithProto() { prepareVMCall(); pushArg(R0); - using Fn = JSObject* (*)(JSContext*, HandleValue); + using Fn = PlainObject* (*)(JSContext*, HandleValue); if (!callVM()) { return false; } diff --git a/js/src/jit/CacheIR.cpp b/js/src/jit/CacheIR.cpp index ce13af8a38a0..46177340b9f0 100644 --- a/js/src/jit/CacheIR.cpp +++ b/js/src/jit/CacheIR.cpp @@ -14,6 +14,7 @@ #include "jit/BaselineIC.h" #include "jit/CacheIRSpewer.h" #include "jit/InlinableNatives.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/SelfHosting.h" #include "jit/MacroAssembler-inl.h" @@ -7069,7 +7070,7 @@ void NewObjectIRGenerator::trackAttached(const char* name) { AttachDecision NewObjectIRGenerator::tryAttachStub() { AutoAssertNoPendingException aanpe(cx_); - if (templateObject_->as().hasDynamicSlots()) { + if (templateObject_->as().hasDynamicSlots()) { trackAttached(IRGenerator::NotAttached); return AttachDecision::NoAction; } diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index 828fc8f8b105..3d9b094b74ef 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -58,6 +58,7 @@ #include "vm/AsyncIteration.h" #include "vm/EqualityOperations.h" // js::SameValue #include "vm/MatchPairs.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/RegExpObject.h" #include "vm/RegExpStatics.h" #include "vm/StringType.h" @@ -13931,7 +13932,7 @@ void CodeGenerator::visitGetPrototypeOf(LGetPrototypeOf* lir) { void CodeGenerator::visitObjectWithProto(LObjectWithProto* lir) { pushArg(ToValue(lir, LObjectWithProto::PrototypeValue)); - using Fn = JSObject* (*)(JSContext*, HandleValue); + using Fn = PlainObject* (*)(JSContext*, HandleValue); callVM(lir); } diff --git a/js/src/jit/IonAnalysis.cpp b/js/src/jit/IonAnalysis.cpp index af5665124113..9edb3e431032 100644 --- a/js/src/jit/IonAnalysis.cpp +++ b/js/src/jit/IonAnalysis.cpp @@ -19,6 +19,7 @@ #include "jit/Lowering.h" #include "jit/MIRGraph.h" #include "util/CheckedArithmetic.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/RegExpObject.h" #include "vm/SelfHosting.h" diff --git a/js/src/jit/IonAnalysis.h b/js/src/jit/IonAnalysis.h index bfdf2f26e39b..43e317b4e061 100644 --- a/js/src/jit/IonAnalysis.h +++ b/js/src/jit/IonAnalysis.h @@ -12,6 +12,9 @@ #include "jit/JitAllocPolicy.h" namespace js { + +class PlainObject; + namespace jit { class MBasicBlock; @@ -160,7 +163,7 @@ MCompare* ConvertLinearInequality(TempAllocator& alloc, MBasicBlock* block, MOZ_MUST_USE bool AnalyzeNewScriptDefiniteProperties( JSContext* cx, DPAConstraintInfo& constraintInfo, HandleFunction fun, - ObjectGroup* group, HandlePlainObject baseobj, + ObjectGroup* group, Handle baseobj, Vector* initializerList); MOZ_MUST_USE bool AnalyzeArgumentsUsage(JSContext* cx, JSScript* script); diff --git a/js/src/jit/IonBuilder.cpp b/js/src/jit/IonBuilder.cpp index 76b0c7f63850..7f9726b1d580 100644 --- a/js/src/jit/IonBuilder.cpp +++ b/js/src/jit/IonBuilder.cpp @@ -30,6 +30,7 @@ #include "vm/EnvironmentObject.h" #include "vm/Instrumentation.h" #include "vm/Opcodes.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/RegExpStatics.h" #include "vm/SelfHosting.h" #include "vm/TraceLogging.h" diff --git a/js/src/jit/MCallOptimize.cpp b/js/src/jit/MCallOptimize.cpp index 9224d9c5958e..fce0fc601a2c 100644 --- a/js/src/jit/MCallOptimize.cpp +++ b/js/src/jit/MCallOptimize.cpp @@ -31,6 +31,7 @@ #include "vm/ArgumentsObject.h" #include "vm/ArrayBufferObject.h" #include "vm/JSObject.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/ProxyObject.h" #include "vm/SelfHosting.h" #include "vm/SharedArrayObject.h" diff --git a/js/src/jit/MIR.cpp b/js/src/jit/MIR.cpp index 7f2a50bd83ac..13ca46b40f9f 100644 --- a/js/src/jit/MIR.cpp +++ b/js/src/jit/MIR.cpp @@ -24,6 +24,7 @@ #include "js/Conversions.h" #include "util/Text.h" #include "util/Unicode.h" +#include "vm/PlainObject.h" // js::PlainObject #include "wasm/WasmCode.h" #include "builtin/Boolean-inl.h" diff --git a/js/src/jit/Recover.cpp b/js/src/jit/Recover.cpp index 9c6410e2f475..67f9a8c45046 100644 --- a/js/src/jit/Recover.cpp +++ b/js/src/jit/Recover.cpp @@ -22,6 +22,7 @@ #include "vm/Iteration.h" #include "vm/JSContext.h" #include "vm/JSObject.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/StringType.h" #include "vm/Interpreter-inl.h" diff --git a/js/src/jit/TemplateObject-inl.h b/js/src/jit/TemplateObject-inl.h index ededf8ef618d..fb8159485019 100644 --- a/js/src/jit/TemplateObject-inl.h +++ b/js/src/jit/TemplateObject-inl.h @@ -9,6 +9,7 @@ #include "jit/TemplateObject.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/RegExpObject.h" namespace js { diff --git a/js/src/jit/VMFunctions.cpp b/js/src/jit/VMFunctions.cpp index 087073a070ee..a888627101dd 100644 --- a/js/src/jit/VMFunctions.cpp +++ b/js/src/jit/VMFunctions.cpp @@ -20,6 +20,7 @@ #include "vm/ArrayObject.h" #include "vm/EqualityOperations.h" // js::StrictlyEqual #include "vm/Interpreter.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/SelfHosting.h" #include "vm/TraceLogging.h" #include "vm/TypedArrayObject.h" diff --git a/js/src/jit/VMFunctions.h b/js/src/jit/VMFunctions.h index cf03277e9ee5..b109829d7d88 100644 --- a/js/src/jit/VMFunctions.h +++ b/js/src/jit/VMFunctions.h @@ -24,6 +24,7 @@ class WithScope; class InlineTypedObject; class AbstractGeneratorObject; class AsyncFunctionGeneratorObject; +class PlainObject; class RegExpObject; class TypedArrayObject; diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 91cae441734e..f91eb6989701 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -87,6 +87,7 @@ #include "vm/JSFunction.h" #include "vm/JSObject.h" #include "vm/JSScript.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/PromiseObject.h" // js::PromiseObject #include "vm/Runtime.h" #include "vm/SavedStacks.h" diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index a4089df556c8..4454a4d70706 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -31,6 +31,7 @@ #include "vm/FrameIter.h" // js::FrameIter #include "vm/JSContext.h" #include "vm/JSObject.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/Printer.h" #include "vm/PromiseObject.h" // js::PromiseObject #include "vm/Realm.h" diff --git a/js/src/proxy/ScriptedProxyHandler.cpp b/js/src/proxy/ScriptedProxyHandler.cpp index af79e1d207e5..ea3912678186 100644 --- a/js/src/proxy/ScriptedProxyHandler.cpp +++ b/js/src/proxy/ScriptedProxyHandler.cpp @@ -13,6 +13,7 @@ #include "vm/EqualityOperations.h" // js::SameValue #include "vm/JSFunction.h" #include "vm/JSObject.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/JSObject-inl.h" #include "vm/NativeObject-inl.h" diff --git a/js/src/vm/AsyncIteration.cpp b/js/src/vm/AsyncIteration.cpp index aae2e4d7cb53..8734b75d9ca6 100644 --- a/js/src/vm/AsyncIteration.cpp +++ b/js/src/vm/AsyncIteration.cpp @@ -13,6 +13,7 @@ #include "vm/GeneratorObject.h" #include "vm/GlobalObject.h" #include "vm/Interpreter.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/PromiseObject.h" // js::PromiseObject #include "vm/Realm.h" #include "vm/SelfHosting.h" diff --git a/js/src/vm/GeneratorObject.cpp b/js/src/vm/GeneratorObject.cpp index 3cc30df41d77..08ada1c7948e 100644 --- a/js/src/vm/GeneratorObject.cpp +++ b/js/src/vm/GeneratorObject.cpp @@ -11,6 +11,7 @@ #include "vm/AsyncIteration.h" #include "vm/GlobalObject.h" #include "vm/JSObject.h" +#include "vm/PlainObject.h" // js::PlainObject #include "debugger/DebugAPI-inl.h" #include "vm/ArrayObject-inl.h" diff --git a/js/src/vm/GlobalObject.h b/js/src/vm/GlobalObject.h index 7f4d3384b40f..fc289aa4e668 100644 --- a/js/src/vm/GlobalObject.h +++ b/js/src/vm/GlobalObject.h @@ -50,6 +50,7 @@ namespace js { class GlobalScope; class LexicalEnvironmentObject; +class PlainObject; class RegExpStatics; class TypeDescr; class TypedObjectModuleObject; diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index 185168fcd0a1..852b9ea9772e 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -49,6 +49,7 @@ #include "vm/JSScript.h" #include "vm/Opcodes.h" #include "vm/PIC.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/Printer.h" #include "vm/Scope.h" #include "vm/Shape.h" @@ -66,6 +67,7 @@ #include "vm/JSScript-inl.h" #include "vm/NativeObject-inl.h" #include "vm/ObjectOperations-inl.h" +#include "vm/PlainObject-inl.h" // js::CopyInitializerObject #include "vm/Probes-inl.h" #include "vm/Stack-inl.h" @@ -975,7 +977,7 @@ bool js::CheckClassHeritageOperation(JSContext* cx, HandleValue heritage) { return false; } -JSObject* js::ObjectWithProtoOperation(JSContext* cx, HandleValue val) { +PlainObject* js::ObjectWithProtoOperation(JSContext* cx, HandleValue val) { if (!val.isObjectOrNull()) { ReportValueError(cx, JSMSG_NOT_OBJORNULL, -1, val, nullptr); return nullptr; diff --git a/js/src/vm/Interpreter.h b/js/src/vm/Interpreter.h index 4d90d377b6ef..cd54e919a6d5 100644 --- a/js/src/vm/Interpreter.h +++ b/js/src/vm/Interpreter.h @@ -21,6 +21,7 @@ namespace js { class EnvironmentIter; +class PlainObject; /* * Convert null/undefined |thisv| into the current global object for the @@ -696,7 +697,7 @@ bool Debug_CheckSelfHosted(JSContext* cx, HandleValue v); bool CheckClassHeritageOperation(JSContext* cx, HandleValue heritage); -JSObject* ObjectWithProtoOperation(JSContext* cx, HandleValue proto); +PlainObject* ObjectWithProtoOperation(JSContext* cx, HandleValue proto); JSObject* FunWithProtoOperation(JSContext* cx, HandleFunction fun, HandleObject parent, HandleObject proto); diff --git a/js/src/vm/Iteration.cpp b/js/src/vm/Iteration.cpp index 35942265e72e..0c2394c7b095 100644 --- a/js/src/vm/Iteration.cpp +++ b/js/src/vm/Iteration.cpp @@ -43,6 +43,7 @@ #include "vm/Compartment-inl.h" #include "vm/JSScript-inl.h" #include "vm/NativeObject-inl.h" +#include "vm/PlainObject-inl.h" // js::PlainObject::createWithTemplate #include "vm/ReceiverGuard-inl.h" #include "vm/Stack-inl.h" #include "vm/StringType-inl.h" diff --git a/js/src/vm/JSContext.cpp b/js/src/vm/JSContext.cpp index f9a52df38e0f..2579aaf1914b 100644 --- a/js/src/vm/JSContext.cpp +++ b/js/src/vm/JSContext.cpp @@ -62,6 +62,7 @@ #include "vm/JSFunction.h" #include "vm/JSObject.h" #include "vm/JSScript.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/Realm.h" #include "vm/Shape.h" #include "vm/StringType.h" // StringToNewUTF8CharsZ diff --git a/js/src/vm/JSFunction.cpp b/js/src/vm/JSFunction.cpp index 97fdf8d36464..1a0f8cf8e860 100644 --- a/js/src/vm/JSFunction.cpp +++ b/js/src/vm/JSFunction.cpp @@ -50,6 +50,7 @@ #include "vm/JSContext.h" #include "vm/JSObject.h" #include "vm/JSScript.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/SelfHosting.h" #include "vm/Shape.h" #include "vm/SharedImmutableStringsCache.h" diff --git a/js/src/vm/JSObject.cpp b/js/src/vm/JSObject.cpp index 72ab46b48f7a..8be762cde0c2 100644 --- a/js/src/vm/JSObject.cpp +++ b/js/src/vm/JSObject.cpp @@ -75,6 +75,7 @@ #include "vm/NativeObject-inl.h" #include "vm/NumberObject-inl.h" #include "vm/ObjectGroup-inl.h" +#include "vm/PlainObject-inl.h" // js::CopyInitializerObject #include "vm/Realm-inl.h" #include "vm/Shape-inl.h" #include "vm/StringObject-inl.h" diff --git a/js/src/vm/JSScript.cpp b/js/src/vm/JSScript.cpp index dd4f45ec78a5..bfa614a715d8 100644 --- a/js/src/vm/JSScript.cpp +++ b/js/src/vm/JSScript.cpp @@ -64,6 +64,7 @@ #include "vm/JSFunction.h" #include "vm/JSObject.h" #include "vm/Opcodes.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/SelfHosting.h" #include "vm/Shape.h" #include "vm/SharedImmutableStringsCache.h" diff --git a/js/src/vm/NativeObject-inl.h b/js/src/vm/NativeObject-inl.h index 98c05e08557b..c40d0b4f221b 100644 --- a/js/src/vm/NativeObject-inl.h +++ b/js/src/vm/NativeObject-inl.h @@ -537,25 +537,6 @@ inline bool NativeObject::isInWholeCellBuffer() const { return nobj; } -/* static */ inline JS::Result -PlainObject::createWithTemplate(JSContext* cx, - Handle templateObject) { - RootedObjectGroup group(cx, templateObject->group()); - MOZ_ASSERT(group->clasp() == &PlainObject::class_); - - gc::InitialHeap heap = GetInitialHeap(GenericObject, group); - - RootedShape shape(cx, templateObject->lastProperty()); - - gc::AllocKind kind = gc::GetGCObjectKind(shape->numFixedSlots()); - MOZ_ASSERT(CanChangeToBackgroundAllocKind(kind, shape->getObjectClass())); - kind = gc::ForegroundToBackgroundAllocKind(kind); - - return create(cx, kind, heap, shape, group).map([](NativeObject* obj) { - return &obj->as(); - }); -} - MOZ_ALWAYS_INLINE bool NativeObject::updateSlotsForSpan(JSContext* cx, size_t oldSpan, size_t newSpan) { @@ -623,38 +604,6 @@ inline js::gc::AllocKind NativeObject::allocKindForTenure() const { inline js::GlobalObject& NativeObject::global() const { return nonCCWGlobal(); } -inline js::gc::AllocKind PlainObject::allocKindForTenure() const { - using namespace js::gc; - AllocKind kind = GetGCObjectFixedSlotsKind(numFixedSlots()); - MOZ_ASSERT(!IsBackgroundFinalized(kind)); - MOZ_ASSERT(CanChangeToBackgroundAllocKind(kind, getClass())); - return ForegroundToBackgroundAllocKind(kind); -} - -/* Make an object with pregenerated shape from a NEWOBJECT bytecode. */ -static inline PlainObject* CopyInitializerObject( - JSContext* cx, HandlePlainObject baseobj, - NewObjectKind newKind = GenericObject) { - MOZ_ASSERT(!baseobj->inDictionaryMode()); - - gc::AllocKind allocKind = - gc::GetGCObjectFixedSlotsKind(baseobj->numFixedSlots()); - allocKind = gc::ForegroundToBackgroundAllocKind(allocKind); - MOZ_ASSERT_IF(baseobj->isTenured(), - allocKind == baseobj->asTenured().getAllocKind()); - RootedPlainObject obj( - cx, NewBuiltinClassInstance(cx, allocKind, newKind)); - if (!obj) { - return nullptr; - } - - if (!obj->setLastProperty(cx, baseobj->lastProperty())) { - return nullptr; - } - - return obj; -} - /* * Call obj's resolve hook. * diff --git a/js/src/vm/NativeObject.cpp b/js/src/vm/NativeObject.cpp index 4790b9bd1420..8ad018c70102 100644 --- a/js/src/vm/NativeObject.cpp +++ b/js/src/vm/NativeObject.cpp @@ -23,6 +23,7 @@ #include "js/Value.h" #include "util/Memory.h" #include "vm/EqualityOperations.h" // js::SameValue +#include "vm/PlainObject.h" // js::PlainObject #include "vm/TypedArrayObject.h" #include "gc/Nursery-inl.h" @@ -2945,7 +2946,7 @@ bool js::NativeDeleteProperty(JSContext* cx, HandleNativeObject obj, bool js::CopyDataPropertiesNative(JSContext* cx, HandlePlainObject target, HandleNativeObject from, - HandlePlainObject excludedItems, + Handle excludedItems, bool* optimized) { MOZ_ASSERT( !target->isDelegate(), diff --git a/js/src/vm/NativeObject.h b/js/src/vm/NativeObject.h index 8e8b89971a21..cba458aa5d00 100644 --- a/js/src/vm/NativeObject.h +++ b/js/src/vm/NativeObject.h @@ -1492,19 +1492,6 @@ class NativeObject : public JSObject { static size_t offsetOfSlots() { return offsetof(NativeObject, slots_); } }; -// Object class for plain native objects created using '{}' object literals, -// 'new Object()', 'Object.create', etc. -class PlainObject : public NativeObject { - public: - static const JSClass class_; - - static inline JS::Result createWithTemplate( - JSContext* cx, Handle templateObject); - - /* Return the allocKind we would use if we were to tenure this object. */ - inline js::gc::AllocKind allocKindForTenure() const; -}; - inline void NativeObject::privateWriteBarrierPre(void** oldval) { JS::shadow::Zone* shadowZone = this->shadowZoneFromAnyThread(); if (shadowZone->needsIncrementalBarrier() && *oldval && @@ -1652,12 +1639,6 @@ bool IsPackedArray(JSObject* obj); extern void AddPropertyTypesAfterProtoChange(JSContext* cx, NativeObject* obj, ObjectGroup* oldGroup); -// Specializations of 7.3.23 CopyDataProperties(...) for NativeObjects. -extern bool CopyDataPropertiesNative(JSContext* cx, HandlePlainObject target, - HandleNativeObject from, - HandlePlainObject excludedItems, - bool* optimized); - // Initialize an object's reserved slot with a private value pointing to // malloc-allocated memory and associate the memory with the object. // diff --git a/js/src/vm/ObjectGroup.cpp b/js/src/vm/ObjectGroup.cpp index 64a09399cdee..98d829c4cc24 100644 --- a/js/src/vm/ObjectGroup.cpp +++ b/js/src/vm/ObjectGroup.cpp @@ -22,6 +22,7 @@ #include "vm/ErrorObject.h" #include "vm/GlobalObject.h" #include "vm/JSObject.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/RegExpObject.h" #include "vm/Shape.h" #include "vm/TaggedProto.h" diff --git a/js/src/vm/ObjectGroup.h b/js/src/vm/ObjectGroup.h index ce5e4fabda91..71c2bfd8666a 100644 --- a/js/src/vm/ObjectGroup.h +++ b/js/src/vm/ObjectGroup.h @@ -28,6 +28,7 @@ class AutoClearTypeInferenceStateOnOOM; class AutoSweepObjectGroup; class CompilerConstraintList; class ObjectGroupRealm; +class PlainObject; namespace gc { void MergeRealms(JS::Realm* source, JS::Realm* target); diff --git a/js/src/vm/PlainObject-inl.h b/js/src/vm/PlainObject-inl.h new file mode 100644 index 000000000000..81956dff63a4 --- /dev/null +++ b/js/src/vm/PlainObject-inl.h @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: set ts=8 sts=2 et sw=2 tw=80: + * 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_PlainObject_inl_h +#define vm_PlainObject_inl_h + +#include "vm/PlainObject.h" + +#include "mozilla/Assertions.h" // MOZ_ASSERT, MOZ_ASSERT_IF + +#include "gc/Allocator.h" // js::gc::InitialHeap +#include "js/RootingAPI.h" // JS::Handle, JS::Rooted +#include "vm/NativeObject.h" // js::NativeObject::create +#include "vm/ObjectGroup.h" // js::ObjectGroup, js::GenericObject +#include "vm/Shape.h" // js::Shape + +#include "gc/ObjectKind-inl.h" // js::gc::GetGCObjectKind +#include "vm/JSObject-inl.h" // js::GetInitialHeap, js::NewBuiltinClassInstance + +/* static */ inline JS::Result +js::PlainObject::createWithTemplate(JSContext* cx, + JS::Handle templateObject) { + JS::Rooted group(cx, templateObject->group()); + MOZ_ASSERT(group->clasp() == &PlainObject::class_); + + gc::InitialHeap heap = GetInitialHeap(GenericObject, group); + + JS::Rooted shape(cx, templateObject->lastProperty()); + + gc::AllocKind kind = gc::GetGCObjectKind(shape->numFixedSlots()); + MOZ_ASSERT(gc::CanChangeToBackgroundAllocKind(kind, shape->getObjectClass())); + kind = gc::ForegroundToBackgroundAllocKind(kind); + + return NativeObject::create(cx, kind, heap, shape, group) + .map([](NativeObject* obj) { return &obj->as(); }); +} + +inline js::gc::AllocKind js::PlainObject::allocKindForTenure() const { + gc::AllocKind kind = gc::GetGCObjectFixedSlotsKind(numFixedSlots()); + MOZ_ASSERT(!gc::IsBackgroundFinalized(kind)); + MOZ_ASSERT(gc::CanChangeToBackgroundAllocKind(kind, getClass())); + return gc::ForegroundToBackgroundAllocKind(kind); +} + +namespace js { + +/* Make an object with pregenerated shape from a NEWOBJECT bytecode. */ +static inline PlainObject* CopyInitializerObject( + JSContext* cx, JS::Handle baseobj, + NewObjectKind newKind = GenericObject) { + MOZ_ASSERT(!baseobj->inDictionaryMode()); + + gc::AllocKind allocKind = + gc::GetGCObjectFixedSlotsKind(baseobj->numFixedSlots()); + allocKind = gc::ForegroundToBackgroundAllocKind(allocKind); + MOZ_ASSERT_IF(baseobj->isTenured(), + allocKind == baseobj->asTenured().getAllocKind()); + JS::Rooted obj( + cx, NewBuiltinClassInstance(cx, allocKind, newKind)); + if (!obj) { + return nullptr; + } + + if (!obj->setLastProperty(cx, baseobj->lastProperty())) { + return nullptr; + } + + return obj; +} + +} // namespace js + +#endif // vm_PlainObject_inl_h diff --git a/js/src/vm/PlainObject.h b/js/src/vm/PlainObject.h new file mode 100644 index 000000000000..3a1270a29c81 --- /dev/null +++ b/js/src/vm/PlainObject.h @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: set ts=8 sts=2 et sw=2 tw=80: + * 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_PlainObject_h +#define vm_PlainObject_h + +#include "gc/AllocKind.h" // js::gc::AllocKind +#include "js/Class.h" // JSClass +#include "js/Result.h" // JS::OOM, JS::Result +#include "js/RootingAPI.h" // JS::Handle +#include "vm/NativeObject.h" // js::NativeObject + +struct JS_PUBLIC_API JSContext; + +namespace js { + +// Object class for plain native objects created using '{}' object literals, +// 'new Object()', 'Object.create', etc. +class PlainObject : public NativeObject { + public: + static const JSClass class_; + + static inline JS::Result createWithTemplate( + JSContext* cx, JS::Handle templateObject); + + /* Return the allocKind we would use if we were to tenure this object. */ + inline gc::AllocKind allocKindForTenure() const; +}; + +// Specializations of 7.3.23 CopyDataProperties(...) for NativeObjects. +extern bool CopyDataPropertiesNative(JSContext* cx, + JS::Handle target, + JS::Handle from, + JS::Handle excludedItems, + bool* optimized); +} // namespace js + +#endif // vm_PlainObject_h diff --git a/js/src/vm/Realm.h b/js/src/vm/Realm.h index 09fc9d842029..591ac3feab8a 100644 --- a/js/src/vm/Realm.h +++ b/js/src/vm/Realm.h @@ -25,6 +25,7 @@ #include "vm/ArrayBufferObject.h" #include "vm/Compartment.h" #include "vm/NativeObject.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/PromiseLookup.h" // js::PromiseLookup #include "vm/ReceiverGuard.h" #include "vm/RegExpShared.h" diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp index 7fb7fb9cacee..9ce6461f4bfe 100644 --- a/js/src/vm/SelfHosting.cpp +++ b/js/src/vm/SelfHosting.cpp @@ -73,6 +73,7 @@ #include "vm/JSFunction.h" #include "vm/JSObject.h" #include "vm/PIC.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/Printer.h" #include "vm/Realm.h" #include "vm/RegExpObject.h" diff --git a/js/src/vm/StructuredClone.cpp b/js/src/vm/StructuredClone.cpp index cb7d080b2360..36bf94751bfa 100644 --- a/js/src/vm/StructuredClone.cpp +++ b/js/src/vm/StructuredClone.cpp @@ -53,6 +53,7 @@ #include "js/Wrapper.h" #include "vm/BigIntType.h" #include "vm/JSContext.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/RegExpObject.h" #include "vm/SavedFrame.h" #include "vm/SharedArrayObject.h" diff --git a/js/src/vm/TypeInference-inl.h b/js/src/vm/TypeInference-inl.h index 2594ea33a2cb..c4eb820f3f8f 100644 --- a/js/src/vm/TypeInference-inl.h +++ b/js/src/vm/TypeInference-inl.h @@ -29,6 +29,7 @@ #include "vm/NativeObject.h" #include "vm/NumberObject.h" #include "vm/ObjectGroup.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/Shape.h" #include "vm/SharedArrayObject.h" #include "vm/StringObject.h" diff --git a/js/src/vm/TypeInference.cpp b/js/src/vm/TypeInference.cpp index f40640cc7164..c02bcd94e518 100644 --- a/js/src/vm/TypeInference.cpp +++ b/js/src/vm/TypeInference.cpp @@ -36,6 +36,7 @@ #include "vm/JSObject.h" #include "vm/JSScript.h" #include "vm/Opcodes.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/Printer.h" #include "vm/Shape.h" #include "vm/Time.h" diff --git a/js/src/vm/TypeInference.h b/js/src/vm/TypeInference.h index c968da26823a..594f9fcc45e7 100644 --- a/js/src/vm/TypeInference.h +++ b/js/src/vm/TypeInference.h @@ -35,6 +35,7 @@ class TypeConstraint; class TypeZone; class CompilerConstraintList; class HeapTypeSetKey; +class PlainObject; namespace jit { diff --git a/js/src/vm/UbiNodeCensus.cpp b/js/src/vm/UbiNodeCensus.cpp index d0f680e44056..be3a50c2632c 100644 --- a/js/src/vm/UbiNodeCensus.cpp +++ b/js/src/vm/UbiNodeCensus.cpp @@ -10,6 +10,7 @@ #include "js/CharacterEncoding.h" #include "util/Text.h" #include "vm/JSContext.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/Printer.h" #include "vm/Realm.h" diff --git a/js/src/wasm/WasmInstance.cpp b/js/src/wasm/WasmInstance.cpp index a00fbf550876..91c398058cc0 100644 --- a/js/src/wasm/WasmInstance.cpp +++ b/js/src/wasm/WasmInstance.cpp @@ -32,6 +32,7 @@ #include "util/StringBuffer.h" #include "util/Text.h" #include "vm/BigIntType.h" +#include "vm/PlainObject.h" // js::PlainObject #include "wasm/WasmBuiltins.h" #include "wasm/WasmModule.h" #include "wasm/WasmStubs.h" diff --git a/js/src/wasm/WasmJS.cpp b/js/src/wasm/WasmJS.cpp index e0f7dab40474..eb4d512d4fa1 100644 --- a/js/src/wasm/WasmJS.cpp +++ b/js/src/wasm/WasmJS.cpp @@ -36,6 +36,7 @@ #include "util/Text.h" #include "vm/ErrorObject.h" #include "vm/Interpreter.h" +#include "vm/PlainObject.h" // js::PlainObject #include "vm/PromiseObject.h" // js::PromiseObject #include "vm/StringType.h" #include "vm/Warnings.h" // js::WarnNumberASCII diff --git a/js/src/wasm/WasmModule.cpp b/js/src/wasm/WasmModule.cpp index cc3769bb237c..252ba6d762f2 100644 --- a/js/src/wasm/WasmModule.cpp +++ b/js/src/wasm/WasmModule.cpp @@ -25,6 +25,7 @@ #include "jit/JitOptions.h" #include "js/BuildId.h" // JS::BuildIdCharVector #include "threading/LockGuard.h" +#include "vm/PlainObject.h" // js::PlainObject #include "wasm/WasmBaselineCompile.h" #include "wasm/WasmCompile.h" #include "wasm/WasmInstance.h"