Skip to content

Commit

Permalink
68.14.0 - js
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedor committed Apr 22, 2024
1 parent 5bf9003 commit 8d3bf7e
Show file tree
Hide file tree
Showing 6,545 changed files with 161,234 additions and 63,110 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 3 additions & 1 deletion js/ipc/WrapperAnswer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/ScriptSettings.h"
#include "xpcprivate.h"
#include "jsfriendapi.h"
#include "js/Class.h"
#include "js/Object.h" // JS::GetBuiltinClass
#include "js/RegExp.h"
#include "jsfriendapi.h"

Expand Down Expand Up @@ -601,7 +603,7 @@ bool WrapperAnswer::RecvGetBuiltinClass(const ObjectId& objId, ReturnStatus* rs,
LOG("%s.getBuiltinClass()", ReceiverObj(objId));

js::ESClass cls;
if (!js::GetBuiltinClass(cx, obj, &cls)) {
if (!JS::GetBuiltinClass(cx, obj, &cls)) {
return fail(jsapi, rs);
}

Expand Down
1 change: 1 addition & 0 deletions js/ipc/WrapperOwner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "mozilla/Unused.h"
#include "mozilla/dom/BindingUtils.h"
#include "jsfriendapi.h"
#include "js/friend/DumpFunctions.h" // js::DumpBacktrace
#include "js/CharacterEncoding.h"
#include "js/RegExp.h"
#include "js/RegExpFlags.h"
Expand Down
66 changes: 23 additions & 43 deletions js/moz.configure
Original file line number Diff line number Diff line change
Expand Up @@ -502,65 +502,45 @@ set_config('JS_HAS_TYPED_OBJECTS', depends_if('--enable-typed-objects')(lambda x
set_define('JS_HAS_TYPED_OBJECTS', depends_if('--enable-typed-objects')(lambda x: True))


# Support for WebAssembly bulk memory operations.
# =====================================================

@depends(milestone.is_nightly)
def default_wasm_bulk_memory(is_nightly):
return is_nightly

js_option('--enable-wasm-bulk-memory',
default=default_wasm_bulk_memory,
help='{Enable|Disable} WebAssembly bulk memory operators')

set_config('ENABLE_WASM_BULKMEM_OPS', depends_if('--enable-wasm-bulk-memory')(lambda x: True))
set_define('ENABLE_WASM_BULKMEM_OPS', depends_if('--enable-wasm-bulk-memory')(lambda x: True))


# Support for WebAssembly reference types.
# =====================================================

@depends(milestone.is_nightly)
def default_wasm_reftypes(is_nightly):
return is_nightly

js_option('--enable-wasm-reftypes',
default=default_wasm_reftypes,
help='{Enable|Disable} WebAssembly reference types')

set_config('ENABLE_WASM_REFTYPES', depends_if('--enable-wasm-reftypes')(lambda x: True))
set_define('ENABLE_WASM_REFTYPES', depends_if('--enable-wasm-reftypes')(lambda x: True))

js_option('--disable-wasm-reftypes',
help='Disable WebAssembly reference types')

# Support for WebAssembly I64/BigInt conversion
# ===========================================================================

@depends(milestone.is_nightly)
def default_wasm_bigint(is_nightly):
return is_nightly

js_option('--enable-wasm-bigint',
default=default_wasm_bigint,
help='{Enable|Disable} WebAssembly I64/BigInt conversion')
@depends('--disable-wasm-reftypes')
def enable_wasm_reftypes(value):
if value:
return True

set_config('ENABLE_WASM_BIGINT', depends_if('--enable-wasm-bigint')(lambda x: True))
set_define('ENABLE_WASM_BIGINT', depends_if('--enable-wasm-bigint')(lambda x: True))
set_config('ENABLE_WASM_REFTYPES', enable_wasm_reftypes)
set_define('ENABLE_WASM_REFTYPES', enable_wasm_reftypes)


# Support for WebAssembly GC.
# ===========================

@depends(milestone.is_nightly, '--enable-wasm-reftypes')
def default_wasm_gc(is_nightly, reftypes):
if reftypes and is_nightly:
@depends(milestone.is_nightly, '--enable-wasm-reftypes', '--enable-typed-objects')
def default_wasm_gc(is_nightly, reftypes, typed_objects):
if is_nightly and reftypes and typed_objects:
return True

js_option('--enable-wasm-gc',
default=default_wasm_gc,
help='{Enable|Disable} WebAssembly GC')

set_config('ENABLE_WASM_GC', depends_if('--enable-wasm-gc')(lambda x: True))
set_define('ENABLE_WASM_GC', depends_if('--enable-wasm-gc')(lambda x: True))
@depends('--enable-wasm-gc', '--enable-wasm-reftypes', '--enable-typed-objects')
def wasm_gc(value, reftypes, typed_objects):
if not value:
return

if reftypes and typed_objects:
return True

die('--enable-wasm-gc only possible with --enable-wasm-reftypes and --enable-typed-objects')

set_config('ENABLE_WASM_GC', wasm_gc)
set_define('ENABLE_WASM_GC', wasm_gc)


# Support for WebAssembly private ref types.
Expand Down
76 changes: 76 additions & 0 deletions js/public/AllocationLogging.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* 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/. */

/*
* Embedder-supplied tracking of the allocation and deallocation of various
* non-garbage-collected objects in SpiderMonkey.
*
* This functionality is intended to track allocation of non-user-visible
* structures, for debugging the C++ of an embedding. It is not intended to
* give the end user visibility into allocations in JS. Instead see
* AllocationRecording.h for such functionality.
*/

#ifndef js_AllocationLogging_h
#define js_AllocationLogging_h

#include "mozilla/MemoryReporting.h"
#include "mozilla/PodOperations.h"

#include <stdint.h> // uint32_t

#include "jstypes.h" // JS_PUBLIC_API

namespace JS {

using LogCtorDtor = void (*)(void*, const char*, uint32_t);

/**
* Set global functions used to monitor classes to highlight leaks.
*
* For each C++ class that uses these mechanisms, the allocation of an instance
* will log the constructor call, and its subsequent deallocation will log the
* destructor call. If only the former occurs, the instance/allocation is
* leaked. With carefully-written logging functions, this can be used to debug
* the origin of the leaks.
*/
extern JS_PUBLIC_API void SetLogCtorDtorFunctions(LogCtorDtor ctor,
LogCtorDtor dtor);

/**
* Log the allocation of |self|, having a type uniquely identified by the string
* |type|, with allocation size |sz|.
*
* You generally should use |JS_COUNT_CTOR| and |JS_COUNT_DTOR| instead of
* using this function directly.
*/
extern JS_PUBLIC_API void LogCtor(void* self, const char* type, uint32_t sz);

/**
* Log the deallocation of |self|, having a type uniquely identified by the
* string |type|, with allocation size |sz|.
*
* You generally should use |JS_COUNT_CTOR| and |JS_COUNT_DTOR| instead of
* using this function directly.
*/
extern JS_PUBLIC_API void LogDtor(void* self, const char* type, uint32_t sz);

/**
* Within each non-delegating constructor of a |Class|, use
* |JS_COUNT_CTOR(Class);| to log the allocation of |this|. (If you do this in
* delegating constructors, you might count a single allocation multiple times.)
*/
#define JS_COUNT_CTOR(Class) \
(::JS::LogCtor(static_cast<void*>(this), #Class, sizeof(Class)))

/**
* Within the destructor of a |Class|, use |JS_COUNT_DTOR(Class);| to log the
* deallocation of |this|.
*/
#define JS_COUNT_DTOR(Class) \
(::JS::LogDtor(static_cast<void*>(this), #Class, sizeof(Class)))

} // namespace JS

#endif // js_AllocationLogging_h
5 changes: 1 addition & 4 deletions js/public/AllocationRecording.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ namespace JS {
struct RecordAllocationInfo {
RecordAllocationInfo(const char16_t* typeName, const char* className,
const char16_t* descriptiveTypeName,
const char* scriptFilename, const char* coarseType,
uint64_t size, bool inNursery)
const char* coarseType, uint64_t size, bool inNursery)
: typeName(typeName),
className(className),
descriptiveTypeName(descriptiveTypeName),
scriptFilename(scriptFilename),
coarseType(coarseType),
size(size),
inNursery(inNursery) {}
Expand All @@ -34,7 +32,6 @@ struct RecordAllocationInfo {
const char16_t* typeName;
const char* className;
const char16_t* descriptiveTypeName;
const char* scriptFilename;

// The coarseType points to a string literal, so does not need to be
// duplicated.
Expand Down
138 changes: 138 additions & 0 deletions js/public/BigInt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/* 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/. */

/* BigInt. */

#ifndef js_BigInt_h
#define js_BigInt_h

#include "mozilla/Range.h" // mozilla::Range

#include <limits> // std::numeric_limits
#include <stdint.h> // int64_t, uint64_t
#include <type_traits> // std::enable_if_t, std::{true,false}_type, std::is_{integral,signed,unsigned}_v
#include <utility> // std::declval

#include "jstypes.h" // JS_PUBLIC_API
#include "js/RootingAPI.h" // JS::Handle
#include "js/Value.h" // JS::Value

struct JS_PUBLIC_API JSContext;

namespace JS {

class JS_PUBLIC_API BigInt;

namespace detail {

extern JS_PUBLIC_API BigInt* BigIntFromInt64(JSContext* cx, int64_t num);
extern JS_PUBLIC_API BigInt* BigIntFromUint64(JSContext* cx, uint64_t num);
extern JS_PUBLIC_API BigInt* BigIntFromBool(JSContext* cx, bool b);

template <typename T, typename = void>
struct NumberToBigIntConverter;

template <typename SignedIntT>
struct NumberToBigIntConverter<
SignedIntT,
std::enable_if_t<std::is_integral_v<SignedIntT> &&
std::is_signed_v<SignedIntT> &&
std::numeric_limits<SignedIntT>::digits <= 64>> {
static BigInt* convert(JSContext* cx, SignedIntT num) {
return BigIntFromInt64(cx, num);
}
};

template <typename UnsignedIntT>
struct NumberToBigIntConverter<
UnsignedIntT,
std::enable_if_t<std::is_integral_v<UnsignedIntT> &&
std::is_unsigned_v<UnsignedIntT> &&
std::numeric_limits<UnsignedIntT>::digits <= 64>> {
static BigInt* convert(JSContext* cx, UnsignedIntT num) {
return BigIntFromUint64(cx, num);
}
};

template <>
struct NumberToBigIntConverter<bool> {
static BigInt* convert(JSContext* cx, bool b) {
return BigIntFromBool(cx, b);
}
};

} // namespace detail

/**
* Create a BigInt from an integer value. All integral types not larger than 64
* bits in size are supported.
*/
template <typename NumericT>
extern JS_PUBLIC_API BigInt* NumberToBigInt(JSContext* cx, NumericT val) {
return detail::NumberToBigIntConverter<NumericT>::convert(cx, val);
}

/**
* Create a BigInt from a floating-point value. If the number isn't integral
* (that is, if it's NaN, an infinity, or contains a fractional component),
* this function returns null and throws an exception.
*
* Passing -0.0 will produce the bigint 0n.
*/
extern JS_PUBLIC_API BigInt* NumberToBigInt(JSContext* cx, double num);

/**
* Create a BigInt by parsing a string using the ECMAScript StringToBigInt
* algorithm (https://tc39.es/ecma262/#sec-stringtobigint). Latin1 and two-byte
* character ranges are supported. It may be convenient to use
* JS::ConstLatin1Chars or JS::ConstTwoByteChars.
*
* (StringToBigInt performs parsing similar to that performed by the |Number|
* global function when passed a string, but it doesn't allow infinities,
* decimal points, or exponential notation, and neither algorithm allows numeric
* separators or an 'n' suffix character. This fast-and-loose description is
* offered purely as a convenience to the reader: see the specification
* algorithm for exact behavior.)
*
* If parsing fails, this function returns null and throws an exception.
*/
extern JS_PUBLIC_API BigInt* StringToBigInt(
JSContext* cx, mozilla::Range<const Latin1Char> chars);

extern JS_PUBLIC_API BigInt* StringToBigInt(
JSContext* cx, mozilla::Range<const char16_t> chars);

/**
* Create a BigInt by parsing a string consisting of an optional sign character
* followed by one or more alphanumeric ASCII digits in the provided radix.
*
* If the radix is not in the range [2, 36], or the string fails to parse, this
* function returns null and throws an exception.
*/
extern JS_PUBLIC_API BigInt* SimpleStringToBigInt(
JSContext* cx, mozilla::Span<const char> chars, unsigned radix);

/**
* Convert a JS::Value to a BigInt using the ECMAScript ToBigInt algorithm
* (https://tc39.es/ecma262/#sec-tobigint).
*
* (Note in particular that this will throw if passed a value whose type is
* 'number'. To convert a number to a BigInt, use one of the overloads of
* JS::NumberToBigInt().)
*/
extern JS_PUBLIC_API BigInt* ToBigInt(JSContext* cx, Handle<Value> val);

/**
* Convert the given BigInt, modulo 2**64, to a signed 64-bit integer.
*/
extern JS_PUBLIC_API int64_t ToBigInt64(BigInt* bi);

/**
* Convert the given BigInt, modulo 2**64, to an unsigned 64-bit integer.
*/
extern JS_PUBLIC_API uint64_t ToBigUint64(BigInt* bi);

} // namespace JS

#endif /* js_BigInt_h */
19 changes: 19 additions & 0 deletions js/public/BuildId.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,25 @@ extern JS_PUBLIC_API void SetProcessBuildIdOp(BuildIdOp buildIdOp);
extern MOZ_MUST_USE JS_PUBLIC_API bool GetOptimizedEncodingBuildId(
BuildIdCharVector* buildId);

/**
* Script bytecode is dependent on the buildId and a few other things.
*
* This function produces a buildId that includes:
*
* * The buildId defined by the embedder-provided BuildIdOp set by
* JS::SetProcessBuildIdOp.
* * Additional bytes describing things like endianness, pointer size and
* other state XDR buffers depend on.
*
* Note: this value may depend on runtime preferences so isn't guaranteed to be
* stable across restarts.
*
* Embedders should use this function to tag transcoded bytecode.
* See Transcoding.h.
*/
extern MOZ_MUST_USE JS_PUBLIC_API bool GetScriptTranscodingBuildId(
BuildIdCharVector* buildId);

} // namespace JS

#endif /* js_BuildId_h */
Loading

0 comments on commit 8d3bf7e

Please sign in to comment.