BOOLEAN_TO_JSVAL
DOUBLE_TO_JSVAL
INT_FITS_IN_JSVAL
INT_TO_JSVAL
JS::Add*Root
JS::AutoIdArray
JS::AutoSaveExceptionState
JS::AutoValueArray
JS::AutoVectorRooter
JS::BooleanValue
JS::Call
JS::CallArgs
JS::CloneFunctionObject
JS::Compile
JS::CompileFunction
JS::CompileOffThread
JS::CompileOptions
JS::Construct
JS::CreateError
JS::CurrentGlobalOrNull
JS::DeflateStringToUTF8Buffer
JS::DoubleNaNValue
JS::DoubleValue
JS::Evaluate
JS::FalseValue
JS::Float32Value
JS::GetDeflatedUTF8StringLength
JS::GetFirstArgumentAsTypeHint
JS::GetSelfHostedFunction
JS::Handle
JS::HandleValueArray
JS::IdentifyStandardInstance
JS::Int32Value
JS::IsCallable
JS::MutableHandle
JS::NewFunctionFromSpec
JS::NullHandleValue
JS::NullValue
JS::NumberValue
JS::ObjectOrNullValue
JS::ObjectValue
JS::OrdinaryToPrimitive
JS::PersistentRooted
JS::PropertySpecNameEqualsId
JS::PropertySpecNameIsSymbol
JS::PropertySpecNameToPermanentId
JS::ProtoKeyToId
JS::Remove*Root
JS::Rooted
JS::SetLargeAllocationFailureCallback
JS::SetOutOfMemoryCallback
JS::SourceBufferHolder
JS::StringValue
JS::SymbolValue
JS::ToBoolean
JS::ToInt32
JS::ToInt64
JS::ToNumber
JS::ToPrimitive
JS::ToString
JS::ToUint16
JS::ToUint32
JS::ToUint64
JS::TrueHandleValue
JS::TrueValue
JS::UndefinedHandleValue
JS::UndefinedValue
JS::Value
JSAutoByteString
JSAutoCompartment
JSBool
JSCheckAccessOp
JSClass
JSClass.call
JSClass.flags
JSConstDoubleSpec
JSConvertOp
JSDeletePropertyOp
JSEnumerateOp
JSErrorFormatString
JSErrorReport
JSExceptionState
JSExnType
JSExtendedClass
JSExtendedClass.outerObject
JSExtendedClass.wrappedObject
JSFUN_BOUND_METHOD
JSFUN_GLOBAL_PARENT
JSFastNative
JSFinalizeOp
JSFreeOp
JSFunction
JSFunctionSpec
JSGetObjectOps
JSHasInstanceOp
JSID_EMPTY
JSID_IS_EMPTY
JSID_IS_GCTHING
JSID_IS_INT
JSID_IS_STRING
JSID_IS_SYMBOL
JSID_IS_VOID
JSID_IS_ZERO
JSID_VOID
JSIdArray
JSIteratorOp
JSMarkOp
JSNative
JSNewEnumerateOp
JSNewResolveOp
JSObject
JSObjectOp
JSObjectOps.defaultValue
JSObjectOps.defineProperty
JSObjectOps.destroyObjectMap
JSObjectOps.dropProperty
JSObjectOps.enumerate
JSObjectOps.getAttributes
JSObjectOps.getProperty
JSObjectOps.getRequiredSlot
JSObjectOps.lookupProperty
JSObjectOps.newObjectMap
JSObjectOps.setProto
JSObjectPrincipalsFinder
JSPRINCIPALS_HOLD
JSPrincipals
JSPrincipalsTranscoder
JSProperty
JSPropertyDescriptor
JSPropertyOp
JSPropertySpec
JSProtoKey
JSReserveSlotsOp
JSResolveOp
JSRuntime
JSSecurityCallbacks.contentSecurityPolicyAllows
JSString
JSStringFinalizer
JSTraceOp
JSType
JSVAL_IS_BOOLEAN
JSVAL_IS_DOUBLE
JSVAL_IS_GCTHING
JSVAL_IS_INT
JSVAL_IS_NULL
JSVAL_IS_NUMBER
JSVAL_IS_OBJECT
JSVAL_IS_PRIMITIVE
JSVAL_IS_STRING
JSVAL_IS_VOID
JSVAL_LOCK
JSVAL_NULL
JSVAL_ONE
JSVAL_TO_BOOLEAN
JSVAL_TO_DOUBLE
JSVAL_TO_GCTHING
JSVAL_TO_INT
JSVAL_TO_OBJECT
JSVAL_TO_STRING
JSVAL_TRUE
JSVAL_UNLOCK
JSVAL_VOID
JSVAL_ZERO
JSVersion
JSXDRObjectOp
JS_ASSERT_STRING_IS_FLAT
JS_Add*Root
JS_AddArgumentFormatter
JS_AddExternalStringFinalizer
JS_AddFinalizeCallback
JS_AliasElement
JS_AliasProperty
JS_AlreadyHasOwnProperty
JS_BeginRequest
JS_BindCallable
JS_BufferIsCompilableUnit
JS_CStringsAreUTF8
JS_CallFunction
JS_CheckAccess
JS_CheckForInterrupt
JS_ClearContextThread
JS_ClearDateCaches
JS_ClearNewbornRoots
JS_ClearNonGlobalObject
JS_ClearPendingException
JS_ClearRegExpStatics
JS_ClearScope
JS_CloneFunctionObject
JS_CompareStrings
JS_CompileFileHandleForPrincipals
JS_CompileFileHandleForPrincipalsVersion
JS_CompileFunction
JS_CompileFunctionForPrincipals
JS_CompileScript
JS_CompileScriptForPrincipals
JS_CompileUCFunctionForPrincipalsVersion
JS_CompileUTF8File
JS_CompileUTF8FileHandle
JS_ConcatStrings
JS_ConstructObject
JS_ContextIterator
JS_ConvertArguments
JS_ConvertArgumentsVA
JS_ConvertValue
JS_DecompileFunction
JS_DecompileFunctionBody
JS_DecompileScript
JS_DecompileScriptObject
JS_DeepFreezeObject
JS_DefaultValue
JS_DefineConstDoubles
JS_DefineElement
JS_DefineFunction
JS_DefineFunctions
JS_DefineObject
JS_DefineOwnProperty
JS_DefineProperties
JS_DefineProperty
JS_DefinePropertyWithTinyId
JS_DeleteElement
JS_DeleteElement2
JS_DeleteProperty
JS_DeleteProperty2
JS_DestroyContext
JS_DestroyIdArray
JS_DestroyRuntime
JS_DestroyScript
JS_DoubleIsInt32
JS_DoubleToInt32
JS_DropExceptionState
JS_DumpHeap
JS_DumpNamedRoots
JS_EncodeCharacters
JS_EncodeString
JS_EncodeStringToBuffer
JS_EnterCompartment
JS_EnterCrossCompartmentCall
JS_EnterLocalRootScope
JS_Enumerate
JS_EnumerateDiagnosticMemoryRegions
JS_EnumerateResolvedStandardClasses
JS_EnumerateStandardClasses
JS_ErrorFromException
JS_EvaluateScript
JS_EvaluateScriptForPrincipals
JS_ExecuteRegExp
JS_ExecuteScript
JS_ExecuteScriptPart
JS_ExecuteScriptVersion
JS_FORGET_STRING_FLATNESS
JS_FS
JS_FileEscapedString
JS_Finish
JS_FlattenString
JS_FlushCaches
JS_ForgetLocalRoot
JS_ForwardGetPropertyTo
JS_FreezeObject
JS_GC
JS_GET_CLASS
JS_GetArrayLength
JS_GetArrayPrototype
JS_GetClass
JS_GetClassObject
JS_GetClassPrototype
JS_GetCompartmentPrivate
JS_GetConstructor
JS_GetContextPrivate
JS_GetContextThread
JS_GetDefaultFreeOp
JS_GetElement
JS_GetEmptyString
JS_GetEmptyStringValue
JS_GetErrorPrototype
JS_GetExternalStringClosure
JS_GetExternalStringFinalizer
JS_GetFlatStringChars
JS_GetFunctionArity
JS_GetFunctionCallback
JS_GetFunctionFlags
JS_GetFunctionId
JS_GetFunctionName
JS_GetFunctionObject
JS_GetFunctionPrototype
JS_GetFunctionScript
JS_GetGCParameter
JS_GetGlobalForCompartmentOrNull
JS_GetGlobalForObject
JS_GetGlobalForObject3
JS_GetGlobalForScopeChain
JS_GetGlobalObject
JS_GetImplementationVersion
JS_GetInstancePrivate
JS_GetInternedStringChars
JS_GetLatin1FlatStringChars
JS_GetLatin1InternedStringChars
JS_GetLatin1StringCharsAndLength
JS_GetLocaleCallbacks
JS_GetNaNValue
JS_GetObjectPrototype
JS_GetObjectRuntime
JS_GetOptions
JS_GetOwnPropertyDescriptor
JS_GetParent
JS_GetParentRuntime
JS_GetPendingException
JS_GetPositiveInfinityValue
JS_GetPrivate
JS_GetProperty
JS_GetPropertyAttributes
JS_GetPropertyAttrsGetterAndSetter
JS_GetPropertyDefault
JS_GetPropertyDescriptor
JS_GetPrototype
JS_GetRegExpFlags
JS_GetRegExpSource
JS_GetReservedSlot
JS_GetRuntime
JS_GetRuntimePrivate
JS_GetScopeChain
JS_GetSecurityCallbacks
JS_GetStringBytes
JS_GetStringCharAt
JS_GetStringChars
JS_GetStringCharsAndLength
JS_GetStringEncodingLength
JS_GetStringLength
JS_GetTwoByteExternalStringChars
JS_GetTypeName
JS_GetVersion
JS_HasArrayLength
JS_HasElement
JS_HasInstance
JS_HasOwnProperty
JS_HasProperty
JS_IdArrayGet
JS_IdArrayLength
JS_IdToProtoKey
JS_IdToValue
JS_Init
JS_InitCTypesClass
JS_InitClass
JS_InitStandardClasses
JS_InstanceOf
JS_InternJSString
JS_InternString
JS_IsArrayObject
JS_IsAssigning
JS_IsBuiltinEvalFunction
JS_IsBuiltinFunctionConstructor
JS_IsConstructing
JS_IsConstructing_PossiblyWithGivenThisObject
JS_IsConstructor
JS_IsExceptionPending
JS_IsExtensible
JS_IsExternalString
JS_IsGlobalObject
JS_IsIdentifier
JS_IsNative
JS_IsNativeFunction
JS_IsRunning
JS_IsStopIteration
JS_IterateCompartments
JS_LeaveCompartment
JS_LeaveCrossCompartmentCall
JS_LeaveLocalRootScope
JS_LeaveLocalRootScopeWithResult
JS_LinkConstructorAndPrototype
JS_Lock
JS_LockGCThing
JS_LookupElement
JS_LookupProperty
JS_LooselyEqual
JS_MakeStringImmutable
JS_MapGCRoots
JS_MaybeGC
JS_New
JS_NewArrayObject
JS_NewCompartmentAndGlobalObject
JS_NewContext
JS_NewDateObject
JS_NewDateObjectMsec
JS_NewDependentString
JS_NewDouble
JS_NewDoubleValue
JS_NewExternalString
JS_NewFunction
JS_NewGlobalObject
JS_NewNumberValue
JS_NewObject
JS_NewObjectForConstructor
JS_NewPlainObject
JS_NewPropertyIterator
JS_NewRegExpObject
JS_NewRuntime
JS_NewScriptObject
JS_NewStringCopyN
JS_NewStringCopyZ
JS_NewUCString
JS_NextProperty
JS_Now
JS_NumberValue
JS_ObjectIsDate
JS_ObjectIsFunction
JS_ObjectIsRegExp
JS_PSGS
JS_ParseJSON
JS_PopArguments
JS_PreventExtensions
JS_PropertyStub
JS_PushArguments
JS_PutEscapedString
JS_Remove*Root
JS_RemoveExternalStringFinalizer
JS_RemoveRootRT
JS_ReportError
JS_ReportErrorNumber
JS_ReportOutOfMemory
JS_ReportPendingException
JS_ResolveStandardClass
JS_RestoreExceptionState
JS_SET_TRACING_DETAILS
JS_SameValue
JS_SaveExceptionState
JS_SaveFrameChain
JS_ScheduleGC
JS_SealObject
JS_SetAllNonReservedSlotsToUndefined
JS_SetArrayLength
JS_SetBranchCallback
JS_SetCallReturnValue2
JS_SetCheckObjectAccessCallback
JS_SetCompartmentNameCallback
JS_SetContextCallback
JS_SetDefaultLocale
JS_SetDestroyCompartmentCallback
JS_SetElement
JS_SetErrorReporter
JS_SetExtraGCRoots
JS_SetFunctionCallback
JS_SetGCCallback
JS_SetGCParametersBasedOnAvailableMemory
JS_SetGCZeal
JS_SetGlobalObject
JS_SetICUMemoryFunctions
JS_SetInterruptCallback
JS_SetNativeStackQuota
JS_SetObjectPrincipalsFinder
JS_SetOperationCallback
JS_SetOptions
JS_SetParent
JS_SetPendingException
JS_SetPrincipalsTranscoder
JS_SetPrivate
JS_SetProperty
JS_SetPropertyAttributes
JS_SetPrototype
JS_SetRegExpInput
JS_SetScriptStackQuota
JS_SetThreadStackLimit
JS_SetVersion
JS_SetVersionForCompartment
JS_ShutDown
JS_StrictlyEqual
JS_StringEqualsAscii
JS_StringHasBeenInterned
JS_StringHasLatin1Chars
JS_StringIsFlat
JS_StringToVersion
JS_SuspendRequest
JS_THREADSAFE
JS_ThrowStopIteration
JS_ToggleOptions
JS_TracerInit
JS_TypeOfValue
JS_Unlock
JS_ValueToBoolean
JS_ValueToECMAInt32
JS_ValueToFunction
JS_ValueToId
JS_ValueToInt32
JS_ValueToNumber
JS_ValueToObject
JS_ValueToSource
JS_ValueToString
JS_VersionToString
JS_YieldRequest
JS_freeop
JS_malloc
JS_updateMallocCounter
OBJECT_TO_JSVAL
PRIVATE_TO_JSVAL
Property attributes
STRING_TO_JSVAL
Stored value
jschar
jsdouble
jsid
jsint
Note that version 1.8.5 is outdated. The latest version of SpiderMonkey can always be found on the source download page.
The Mozilla JavaScript team is pleased to announce the release of SpiderMonkey 1.8.5. You can download full source code here: http://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz (MD5 checksum: a4574365938222adca0a6bd33329cb32
).
SpiderMonkey 1.8.5 is the JavaScript engine that shipped in Firefox 4.0. It is much faster than SpiderMonkey 1.8, implements ES-5 (ECMA 262, 5th Edition), and contains many new language and API features, described in detail below.
Please let us know about your experiences with this release by posting in the mozilla.dev.tech.js-engine newsgroup. Or, file bugs at bugzilla.mozilla.org under Product: Core, Component: JavaScript engine.
—22 March 2011
SpiderMonkey 1.8.5 is supported on all the platforms where Firefox 4 runs.
SpiderMonkey 1.8.5 includes a just-in-time compiler (JIT) (several, actually) that compiles JavaScript to machine code, for a significant speed increase. It is supported only on x86, x86_64 and ARM architectures. On other platforms, the JIT is simply disabled; JavaScript code runs in an interpreter, as in previous versions. It's the same language, just not as fast.
The following features in earlier versions of SpiderMonkey have been dropped.
configure
-based build system, introduced shortly after active development on the engine moved from CVS to Mercurial.SpiderMonkey 1.8.5 is not binary-compatible with previous releases, nor is it source-code compatible. Many JSAPI types, functions, and callback signatures have changed, though most of them still have the same names and do the same things. Applications will need significant changes, but most of those changes will be detected by the C/C++ compiler, so they are easy to detect and updating the code is a fairly straightforward job. Here is a list of the most significant changes.
JSBool strict
parameter to each setter function. It is safe for the setter to ignore the value of the argument.These and other changes are explained in detail below.
JavaScript 1.8.5 adds support for ECMAScript Edition 5, including ES5 strict mode. For details, see New in JavaScript 1.8.5. Note that there are a very small number of incompatibilities between ES5 and and ES3, the version of ECMAScript supported by SpiderMonkey versions 1.5 through 1.8. These are discussed in Annex E of the ES5 specification.
SpiderMonkey 1.8.5 also ships with js-ctypes, a foreign-function interface for privileged JavaScript. To enable js-ctypes in your embedding, you must configure with the --enable-ctypes option and choose one of the configuration options to enable NSPR (e.g. --with-system-nspr
).
SpiderMonkey 1.8.5 introduces a conservative stack-scanning garbage collector. Unlike the exact garbage collector, the new garbage collector will scan the C stack and registers in your embedding, looking for bits that it can treat as potential GC roots. The approach eliminates the need for the JS_EnterLocalRootScope API, and in many cases the need to explicitly root GC things or use the "root as you go" approach popular with earlier SpiderMonkey releases. Since this is a conservative collector, it will often find "garbage" addresses which can trigger warnings from certain code analysis tools. If you are running valgrind on your embedding, be sure to build SpiderMonkey with the --enable-valgrind option to suppress superflous error messages triggered by the garbage collector. This also means that objects will be finalized in a non-deterministic order in SpiderMonkey 1.8.5. This is not a bug, and, any embedding which depends upon deterministic finalization is fatally flawed.
The rooting API has been changed from an error-prone void ** interface to an interface which accepts pointers to specific types. JS_AddRoot has been replaced by JS_AddObjectRoot, JS_AddValueRoot and JS_AddStringRoot; similar changes were made for JS_AddNamedRoot and JS_RemoveRoot. Since jsdoubles are now stored in the jsval, instead of on the heap, we no longer need to define roots for them.
SpiderMonkey 1.8.5 introduces the concept of compartments. A compartment is a global object, a context, and a set of related objects with no outside references (CrossCompartment wrappers excepted). The new garbage collector can perform per-container garbage collection, which can be a significant performance improvement for certain workloads. No compartment may execute JS code or call into JSAPI on two OS threads at the same time. For more information, see SpiderMonkey compartments.
The base data type, jsval, which represents all possible values in JavaScript, has changed from 32- to 64-bits wide, and the underlying representation has changed from a C integer type to a C struct. This change to a struct means that certain tricks, such as writing switch statements in C with jsval cases are no longer legal. Additionally, because not all fields are used by all jsvals, it is no longer safe to compare jsvals as though they were C values. Instead, jsvals should be converted to their C equivalents with the appropriate JSVAL_TO_* macro and then compared.
JSAPI no longer represents floating-point numbers (and integers more than 31 bits long) as pointers to jsdouble; instead, the jsdouble value is directly stored in the jsval. This affects macros like DOUBLE_TO_JSVAL and JSVAL_TO_DOUBLE, which now operate directly on jsdouble rather than jsdouble pointers.
Previous SpiderMonkey versions usually represented integer values smaller than 2^31 as jsvals encoding jsint; e.g. so that JSVAL_IS_INT was true. While this was never specified behaviour, it is no longer true; numeric values which are integers are frequently encoded as jsdouble inside the jsval. Embedders must be careful when converting numbers from jsvals into C. Note also that SpiderMonkey can now fit a full 32-bit integer (jsint) inside a jsval without promoting to a jsdouble.
JSExtendedClass has been removed from the API entirely.
Previous SpiderMonkey versions could freely interchange jsid and jsval. They are no longer compatible; using JS_ValueToId and JS_IdToValue to convert between the two is mandatory.
Previous versions of JSAPI supported two types of native functions -- JSNative and JSFastNative. The so-called "Slow Natives" are no longer supported; as such JSFastNative has been renamed to JSNative and relevant interfaces have been updated accordingly. Embedders converting functions from old-JSNative to new-JSNative (JSFastNative) should study the JSFastNative documentation thoroughly, and pay particular that they do not reference negative indices of argv in SpiderMonkey 1.8.5; the JS_CALLEE, JS_THIS, etc. macros must be used instead. See bug 581263.
Global objects have been specialized, and must be be created with either JS_NewGlobalObject or JS_NewCompartmentAndGlobalObject. JS_NewObject and JS_NewObjectWithGivenProto remain the correct APIs for creating other objects. Global objects must also have the JSCLASS_GLOBAL_FLAGS flag set. Merely setting JSCLASS_IS_GLOBAL is insufficient.
JS_ASSERT_STRING_IS_FLAT
JS_AddGCThingRoot
JS_AddNamedGCThingRoot
JS_AddNamedObjectRoot
JS_AddNamedStringRoot
JS_AddNamedValueRoot
JS_AddObjectRoot
JS_AddStringRoot
JS_AddValueRoot
JS_AlreadyHasOwnPropertyById
JS_AnchorPtr
JS_BeginJSONParse (removed in future releases, replaced with JS_ParseJSON)
JS_CompileFileHandleForPrincipalsVersion
JS_CompileScriptForPrincipalsVersion
JS_CompileUCFunctionForPrincipalsVersion
JS_CompileUCScriptForPrincipalsVersion
JS_ConsumeJSONText (removed in future releases, replaced with JS_ParseJSON)
JS_DecompileScriptObject
JS_DeepFreezeObject
JS_DefineFunctionById
JS_DefineOwnProperty
JS_DefinePropertyById
JS_DeletePropertyById
JS_DeletePropertyById2
JS_DoubleIsInt32
JS_EncodeStringToBuffer
JS_EnterCrossCompartmentCall
JS_EvaluateScriptForPrincipalsVersion
JS_EvaluateUCScriptForPrincipalsVersion
JS_ExecuteRegExp
JS_ExecuteRegExpNoStatics
JS_ExecuteScriptVersion
JS_FORGET_STRING_FLATNESS
JS_FileEscapedString
JS_FinishJSONParse (removed in future releases, replaced with JS_ParseJSON)
JS_FlatStringEqualsAscii
JS_FlattenString
JS_FlushCaches
JS_FreezeObject
JS_GetCompartmentPrivate
JS_GetEmptyString
JS_GetFlatStringChars
JS_GetGCParameter
JS_GetGCParameterForThread
JS_GetGlobalForScopeChain
JS_GetInternedStringChars
JS_GetInternedStringCharsAndLength
JS_GetOwnPropertyDescriptor
JS_GetPropertyAttrsGetterAndSetterById
JS_GetPropertyById
JS_GetPropertyByIdDefault
JS_GetPropertyDefault
JS_GetPropertyDescriptorById
JS_GetRuntimeSecurityCallbacks
JS_GetSecurityCallbacks
JS_GetStringCharsAndLength
JS_GetStringCharsZ
JS_GetStringCharsZAndLength
JS_GetStringEncodingLength
JS_HasPropertyById
JS_InitCTypesClass
JS_InternJSString
JS_IsConstructing_PossiblyWithGivenThisObject
JS_IsExtensible
JS_IsInRequest
JS_LeaveCrossCompartmentCall
JS_LookupPropertyById
JS_LookupPropertyWithFlagsById
JS_New
JS_NewCompartmentAndGlobalObject
JS_NewDateObject
JS_NewDateObjectMsec
JS_NewFunctionById
While JSAPI remains a C API, the engine is now implemented in C++. Some C++ helpers have been introduced into the API, to help embedders writing C++ projects. Please note that SpiderMonkey reserves the JS:: namespace for itself.
JS_ClearNewbornRoots
JS_EnterLocalRootScope
JS_LeaveLocalRootScope
JS_LeaveLocalRootScopeWithResult
JS_ForgetLocalRoot
JS_NewGrowableString
JS_AddNamedRoot
– use JS_Add*RootJS_AddNamedRootRT
– use JS_Add*RootJS_AddRoot
– use JS_Add*RootJS_ClearNewbornRoots
– no longer neededJS_ClearOperationCallback
JS_ClearRegExpRoots
JS_DecompileScript
JS_DestroyScript
JS_EnterLocalRootScope
JS_ExecuteScriptPart
JS_ForgetLocalRoot
JS_GetFunctionName
JS_GetOperationLimit
JS_GetScriptObject
JS_GetStringBytes
JS_GetStringChars
JS_IsAssigning
JS_LeaveLocalRootScope
JS_LeaveLocalRootScopeWithResult
JS_NewDouble
JS_NewDoubleValue
JS_NewScriptObject
JS_NewString
JS_PopArguments
JS_PushArguments
JS_PushArgumentsVA
JS_RemoveRoot
JS_RemoveRootRT
JS_SealObject
JS_SetBranchCallback
JS_SetCallReturnValue2
JS_SetCheckObjectAccessCallback
JS_SetObjectPrincipalsFinder
JS_SetOperationLimit
JS_SetPrincipalsTranscoder
JS_SetOperationCallback
was introduced in JS 1.8.0, replacing the branch callback, in anticipation of the addition of the tracing JIT (TraceMonkey). The interface was finalized only after JS 1.8.0 shipped, with bug 477187. The primary change in this interface is that it no longer counts operations; embedders are expected find another mechanism (such as a watchdog thread) to trigger regular callbacks, via JS_TriggerOperationCallback
.
JS_ClearRegExpStatics
, JS_NewRegExpObject
, JS_NewRegUCExpObject
, and JS_SetRegExpInput
now receive a pointer to the global object. This change was made in bug 571355 to move the regexp statics out of the context, to simplify cross compartment wrappers.
JS_PropertyStub
, JS_ResolveStub
, and user-defined functions of type JSPropertyOp
(e.g. getters and setters) changed from passing jsval
s to passing jsid
as part of bug 549143. This bug introduced "fat" (64-bit) unboxed valued into the engine.
JS_MarkGCThing
was changed in bug 549143 to mark jsval
s rather than void pointers (GC root addresses), improving the typed rooting API which was introduced in bug 565157. A conservative stack-scanning collector was also added for SpiderMonkey 1.8.5, making the *LocalRootScope APIs obsolete; they are now NOPs. bug 614138 introduces a C++ JS::Anchor<>
template class to help tie lexical scope to the conservative GC for cases where the compiler might optimize away important stack/register roots (such as when we access the jschars in a JSString). A C analogue, JS_AnchorPtr
, was introduced with bug 630209.
bug 630209 also removed the need for JS_NewScriptObject
, by modifying the script compilation interfaces to handle the creation and management of the object wrapper directly; similarly, the script execution interfaces now accept a JSObject pointer than a pointer to JSScript. Affected interfaces are:
JS_CompileScript
JS_CompileScriptForPrincipals
JS_CompileScriptForPrincipalsVersion
JS_CompileUCScript
JS_CompileUCScriptForPrincipals
JS_CompileUCScriptForPrincipalsVersion
JS_CompileFile
JS_CompileFileHandle
JS_CompileFileHandleForPrincipals
JS_CompileFileHandleForPrincipalsVersion
JS_CompileFunction
JS_CompileFunctionForPrincipals
JS_CompileUCFunctionForPrincipalsVersion
JS_ExecuteScript
JS_ExecuteScriptVersion
JSNative
s now use the "fast native" calling convention; see bug 581263. The JS_FS
macro has been adjusted, losing its third (unused) argument. JS_IsConstructing
, used to differentiate between calls to native constructors with and without the new keyword, now takes a pointer to the native's vp
, along with the native's context pointer, to figure out how the function was called.
JS_CompareStrings
received a new function signature with bug 609440, allowing us to correctly propagate exceptions when the underlying functions to retrieve the characters in the string failed. Additionally, JS_NewString
, JS_GetStringBytes
, and JS_GetStringChars
were removed, replaced by fallible interfaces like JS_GetStringCharsZAndLength
and JS_EncodeStringToBuffer
(not an exhaustive list).
SpiderMonkey 1.8.5 now stores integers up to 32-bits in the jsval. This means that the INT_FITS_IN_JSVAL
macro is always returns true (be careful to only use this macro with jsint
s
, not 64-bit integers). The jsval now also stores jsdouble
s
directly, rather than storing them on the heap. The JSVAL_TO_DOUBLE
and DOUBLE_TO_JSVAL
macros have been updated to work directly on jsdouble
s
rather than their pointers, and the JS_NewDoubleValue
and JS_NewDouble
interfaces have been removed.
There are many new built-in functions in the JavaScript shell, mostly useful for testing SpiderMonkey. The scatter
function has been removed, and a shell worker class (similar to HTML DOM Workers) has been added.
SpiderMonkey will not build with certain builds of Apple's GCC 4.2 C++ compiler. To check what version you are running, issue the command /usr/bin/g++-4.2 -v from a Terminal window. The following builds are known to not work:
To work around this issue, either upgrade your XCode or use an alternate version of GCC, such as the one that shipped with Leopard. To select an alternate C++ compiler, invoke configure thus:
CXX=/usr/bin/g++-4.0 /path/configure --my-configuration-options
The new configure-based build system does not correctly generate the js-config script on many platforms, nor when js-ctypes are enabled. If you are building your project with a GNU-make based build system, the following workaround can be integrated into your build system to generate the correct LDFLAGS, with a strong likelihood that it will work with future versions when js-config is fixed:
JS_CONFIG ?= /path/to/js-config
UNAME_SYSTEM = $(shell uname -s)
JSAPI_LDFLAGS = $(shell $(JS_CONFIG) --libs)
ifeq ($(UNAME_SYSTEM),Darwin)
JSAPI_LDFLAGS := $(filter -l%,$(JSAPI_LDFLAGS)) $(filter -L%,$(JSAPI_LDFLAGS))\
$(filter -%_namespace,$(JSAPI_LDFLAGS))\
$(filter -Wl%,$(JSAPI_LDFLAGS))
JSAPI_LDFLAGS := $(filter-out $(MOZJS_INSTALL_NAME_OPT),$(JSAPI_LDFLAGS))
endif
JSAPI_LDFLAGS := $(filter-out %libffi.a,$(JSAPI_LDFLAGS))
LDFLAGS += $(JSAPI_LDFLAGS)
The SpiderMonkey 1.8.5 source release includes an experimental library versioning scheme. This versioning scheme will not be rolled back into the upstream Mozilla source tree(s), and may not be used in future source releases. Comments in bug 628723 with regard to its usefulness are appreciated. Bugs with the source release tar ball should be copied to wes
@page.ca
.
SpiderMonkey embedders should also be aware that
This is a list of changes which need to be made to the release notes ASAP. Feel free to fix any problems you spot -- this is a Wiki!