temp commit for try run draft
authorPhilip Chimento <philip.chimento@gmail.com>
Mon, 03 Aug 2020 19:12:21 -0700
changeset 3102914 69e4e4f8ccee6c2b1195fdae85409c6d6502ec90
parent 3102572 255b4f5888e9e9cdd40f59fec969af247859d76a
child 3102915 7736458981926f6bfe043849dd340f45d568e2e2
push id578519
push userphilip.chimento@gmail.com
push dateTue, 04 Aug 2020 02:13:54 +0000
treeherdertry@773645898192 [default view] [failures only]
milestone81.0a1
temp commit for try run
js/public/experimental/CodeCoverage.h
js/src/builtin/TestingFunctions.cpp
js/src/jsfriendapi.cpp
js/src/jsfriendapi.h
js/src/moz.build
js/src/shell/js.cpp
js/src/vm/BytecodeUtil.cpp
new file mode 100644
--- /dev/null
+++ b/js/public/experimental/CodeCoverage.h
@@ -0,0 +1,39 @@
+/* -*- 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 js_experimental_CodeCoverage_h
+#define js_experimental_CodeCoverage_h
+
+#include "jstypes.h"  // JS_FRIEND_API
+#include "js/Utility.h"
+
+struct JS_PUBLIC_API JSContext;
+
+namespace js {
+
+/**
+ * Must be called before a runtime is created and before any calls to
+ * GetCodeCoverageSummary.
+ */
+extern JS_FRIEND_API void EnableCodeCoverage();
+
+/**
+ * Generate lcov trace file content for the current realm, and allocate a new
+ * buffer and return the content in it, the size of the newly allocated content
+ * within the buffer would be set to the length out-param. The 'All' variant
+ * will collect data for all realms in the runtime.
+ *
+ * In case of out-of-memory, this function returns nullptr. The length
+ * out-param is undefined on failure.
+ */
+extern JS_FRIEND_API JS::UniqueChars GetCodeCoverageSummary(JSContext* cx,
+                                                            size_t* length);
+extern JS_FRIEND_API JS::UniqueChars GetCodeCoverageSummaryAll(JSContext* cx,
+                                                               size_t* length);
+
+}  // namespace js
+
+#endif  // js_experimental_CodeCoverage_h
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -50,17 +50,18 @@
 #include "jit/JitRealm.h"
 #include "js/Array.h"        // JS::NewArrayObject
 #include "js/ArrayBuffer.h"  // JS::{DetachArrayBuffer,GetArrayBufferLengthAndData,NewArrayBufferWithContents}
 #include "js/CharacterEncoding.h"
 #include "js/CompilationAndEvaluation.h"
 #include "js/CompileOptions.h"
 #include "js/Date.h"
 #include "js/Debug.h"
-#include "js/experimental/TypedData.h"  // JS_GetObjectAsUint8Array
+#include "js/experimental/CodeCoverage.h"  // js::GetCodeCoverageSummary
+#include "js/experimental/TypedData.h"     // JS_GetObjectAsUint8Array
 #include "js/friend/DumpFunctions.h"  // js::Dump{Backtrace,Heap,Object}, JS::FormatStackDump, js::IgnoreNurseryObjects
 #include "js/friend/WindowProxy.h"    // js::ToWindowProxyIfWindow
 #include "js/HashTable.h"
 #include "js/LocaleSensitive.h"
 #include "js/PropertySpec.h"
 #include "js/RegExpFlags.h"  // JS::RegExpFlag, JS::RegExpFlags
 #include "js/SourceText.h"
 #include "js/StableStringChars.h"
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -15,16 +15,17 @@
 
 #include "builtin/BigInt.h"
 #include "builtin/MapObject.h"
 #include "builtin/TestingFunctions.h"
 #include "gc/GC.h"
 #include "gc/PublicIterators.h"
 #include "gc/WeakMap.h"
 #include "js/CharacterEncoding.h"
+#include "js/experimental/CodeCoverage.h"
 #include "js/friend/StackLimits.h"  // JS_STACK_GROWTH_DIRECTION
 #include "js/friend/WindowProxy.h"  // js::ToWindowIfWindowProxy
 #include "js/Printf.h"
 #include "js/Proxy.h"
 #include "js/Wrapper.h"
 #include "proxy/DeadObjectProxy.h"
 #include "util/Poison.h"
 #include "vm/ArgumentsObject.h"
@@ -861,16 +862,18 @@ AutoAssertNoContentJS::AutoAssertNoConte
 AutoAssertNoContentJS::~AutoAssertNoContentJS() {
   context_->runtime()->allowContentJS_ = prevAllowContentJS_;
 }
 
 JS_FRIEND_API void js::EnableAccessValidation(JSContext* cx, bool enabled) {
   cx->enableAccessValidation = enabled;
 }
 
+JS_FRIEND_API void js::EnableCodeCoverage() { js::coverage::EnableLCov(); }
+
 JS_FRIEND_API void js::SetRealmValidAccessPtr(JSContext* cx,
                                               JS::HandleObject global,
                                               bool* accessp) {
   MOZ_ASSERT(global->is<GlobalObject>());
   global->as<GlobalObject>().realm()->setValidAccessPtr(accessp);
 }
 
 JS_FRIEND_API bool js::SystemZoneAvailable(JSContext* cx) { return true; }
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -822,30 +822,16 @@ JS_FRIEND_API void StopPCCountProfiling(
 JS_FRIEND_API void PurgePCCounts(JSContext* cx);
 
 JS_FRIEND_API size_t GetPCCountScriptCount(JSContext* cx);
 
 JS_FRIEND_API JSString* GetPCCountScriptSummary(JSContext* cx, size_t script);
 
 JS_FRIEND_API JSString* GetPCCountScriptContents(JSContext* cx, size_t script);
 
-/**
- * Generate lcov trace file content for the current realm, and allocate a new
- * buffer and return the content in it, the size of the newly allocated content
- * within the buffer would be set to the length out-param. The 'All' variant
- * will collect data for all realms in the runtime.
- *
- * In case of out-of-memory, this function returns nullptr. The length
- * out-param is undefined on failure.
- */
-JS_FRIEND_API JS::UniqueChars GetCodeCoverageSummary(JSContext* cx,
-                                                     size_t* length);
-JS_FRIEND_API JS::UniqueChars GetCodeCoverageSummaryAll(JSContext* cx,
-                                                        size_t* length);
-
 using DOMInstanceClassHasProtoAtDepth = bool (*)(const JSClass*, uint32_t,
                                                  uint32_t);
 struct JSDOMCallbacks {
   DOMInstanceClassHasProtoAtDepth instanceClassMatchesProto;
 };
 using DOMCallbacks = struct JSDOMCallbacks;
 
 extern JS_FRIEND_API void SetDOMCallbacks(JSContext* cx,
--- a/js/src/moz.build
+++ b/js/src/moz.build
@@ -215,16 +215,17 @@ EXPORTS.js += [
 EXPORTS.js += [
     '../../mozglue/baseprofiler/public/ProfilingCategoryList.h',
 ]
 
 # Public APIs that are experimental: the precise contour of the APIs may still
 # change, but they're at least plausible first passes at designing something.
 # We expose them as-is, buyer beware.
 EXPORTS.js.experimental += [
+    '../public/experimental/CodeCoverage.h',
     '../public/experimental/SourceHook.h',
     '../public/experimental/TypedData.h',
 ]
 
 # Friend APIs are APIs that either basically SpiderMonkey-internal, or their
 # contours are gross and terrible -- but the functionality is too important to
 # some embedder (often, Gecko) to just not expose anything or to agonize through
 # a clean design.  Use this only if you absolutely must, and feel free to
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -96,23 +96,24 @@
 #include "js/Array.h"        // JS::NewArrayObject
 #include "js/ArrayBuffer.h"  // JS::{CreateMappedArrayBufferContents,NewMappedArrayBufferWithContents,IsArrayBufferObject,GetArrayBufferLengthAndData}
 #include "js/BuildId.h"      // JS::BuildIdCharVector, JS::SetProcessBuildIdOp
 #include "js/CharacterEncoding.h"  // JS::StringIsASCII
 #include "js/CompilationAndEvaluation.h"
 #include "js/CompileOptions.h"
 #include "js/ContextOptions.h"  // JS::ContextOptions{,Ref}
 #include "js/Debug.h"
-#include "js/Equality.h"                 // JS::SameValue
-#include "js/ErrorReport.h"              // JS::PrintError
-#include "js/Exception.h"                // JS::StealPendingExceptionStack
-#include "js/experimental/SourceHook.h"  // js::{Set,Forget,}SourceHook
-#include "js/experimental/TypedData.h"   // JS_NewUint8Array
-#include "js/friend/DumpFunctions.h"     // JS::FormatStackDump
-#include "js/friend/StackLimits.h"       // js::CheckRecursionLimitConservative
+#include "js/Equality.h"                   // JS::SameValue
+#include "js/ErrorReport.h"                // JS::PrintError
+#include "js/Exception.h"                  // JS::StealPendingExceptionStack
+#include "js/experimental/SourceHook.h"    // js::{Set,Forget,}SourceHook
+#include "js/experimental/CodeCoverage.h"  // js::EnableCodeCoverage
+#include "js/experimental/TypedData.h"     // JS_NewUint8Array
+#include "js/friend/DumpFunctions.h"       // JS::FormatStackDump
+#include "js/friend/StackLimits.h"  // js::CheckRecursionLimitConservative
 #include "js/friend/WindowProxy.h"  // js::IsWindowProxy, js::SetWindowProxyClass, js::ToWindowProxyIfWindow, js::ToWindowIfWindowProxy
 #include "js/GCAPI.h"               // JS::AutoCheckCannotGC
 #include "js/GCVector.h"
 #include "js/Initialization.h"
 #include "js/JSON.h"
 #include "js/MemoryFunctions.h"
 #include "js/Modules.h"  // JS::GetModulePrivate, JS::SetModule{DynamicImport,Metadata,Resolve}Hook, JS::SetModulePrivate
 #include "js/Printf.h"
@@ -11270,17 +11271,17 @@ int main(int argc, char** argv, char** e
 #endif
 
   if (op.getBoolOption("no-threads")) {
     js::DisableExtraThreads();
   }
 
   enableCodeCoverage = op.getBoolOption("code-coverage");
   if (enableCodeCoverage) {
-    coverage::EnableLCov();
+    js::EnableCodeCoverage();
   }
 
 #ifdef JS_WITHOUT_NSPR
   if (!op.getMultiStringOption("dll").empty()) {
     fprintf(stderr, "Error: --dll requires NSPR support!\n");
     return EXIT_FAILURE;
   }
 #else
--- a/js/src/vm/BytecodeUtil.cpp
+++ b/js/src/vm/BytecodeUtil.cpp
@@ -28,16 +28,17 @@
 #include "jsnum.h"
 #include "jstypes.h"
 
 #include "frontend/BytecodeCompiler.h"
 #include "frontend/SourceNotes.h"  // SrcNote, SrcNoteType, SrcNoteIterator
 #include "gc/PublicIterators.h"
 #include "jit/IonScript.h"  // IonBlockCounts
 #include "js/CharacterEncoding.h"
+#include "js/experimental/CodeCoverage.h"
 #include "js/friend/DumpFunctions.h"  // js::DumpPC, js::DumpScript
 #include "js/Printf.h"
 #include "js/Symbol.h"
 #include "util/Memory.h"
 #include "util/StringBuffer.h"
 #include "util/Text.h"
 #include "vm/BytecodeLocation.h"
 #include "vm/CodeCoverage.h"