#include <wtf/HashMap.h>
#include <wtf/HashTraits.h>
#include <wtf/MathExtras.h>
+#include <wtf/MediaTime.h>
#include <wtf/StdLibExtras.h>
#include <wtf/TriState.h>
class JSGlobalObject;
class JSObject;
class JSString;
+class Identifier;
class PropertyName;
class PropertySlot;
class PutPropertySlot;
+class Structure;
#if ENABLE(DFG_JIT)
namespace DFG {
class JITCompiler;
int64_t tryConvertToInt52(double);
bool isInt52(double);
+enum class SourceCodeRepresentation {
+ Other,
+ Integer,
+ Double
+};
+
class JSValue {
friend struct EncodedJSValueHashTraits;
+ friend struct EncodedJSValueWithRepresentationHashTraits;
friend class AssemblyHelpers;
friend class JIT;
friend class JITSlowPathCall;
explicit JSValue(long long);
explicit JSValue(unsigned long long);
- typedef void* (JSValue::*UnspecifiedBoolType);
- operator UnspecifiedBoolType*() const;
+ explicit operator bool() const;
bool operator==(const JSValue& other) const;
bool operator!=(const JSValue& other) const;
bool isMachineInt() const;
bool isNumber() const;
bool isString() const;
+ bool isSymbol() const;
bool isPrimitive() const;
bool isGetterSetter() const;
bool isCustomGetterSetter() const;
// been set in the ExecState already.
double toNumber(ExecState*) const;
JSString* toString(ExecState*) const;
+ Identifier toPropertyKey(ExecState*) const;
WTF::String toWTFString(ExecState*) const;
- WTF::String toWTFStringInline(ExecState*) const;
JSObject* toObject(ExecState*) const;
JSObject* toObject(ExecState*, JSGlobalObject*) const;
// Integer conversions.
JS_EXPORT_PRIVATE double toInteger(ExecState*) const;
- double toIntegerPreserveNaN(ExecState*) const;
+ JS_EXPORT_PRIVATE double toIntegerPreserveNaN(ExecState*) const;
int32_t toInt32(ExecState*) const;
uint32_t toUInt32(ExecState*) const;
- // Floating point conversions (this is a convenience method for webcore;
- // signle precision float is not a representation used in JS or JSC).
+ // Floating point conversions (this is a convenience function for WebCore;
+ // single precision float is not a representation used in JS or JSC).
float toFloat(ExecState* exec) const { return static_cast<float>(toNumber(exec)); }
// Object operations, with the toObject operation included.
JSValue get(ExecState*, PropertyName, PropertySlot&) const;
JSValue get(ExecState*, unsigned propertyName) const;
JSValue get(ExecState*, unsigned propertyName, PropertySlot&) const;
+
+ bool getPropertySlot(ExecState*, PropertyName, PropertySlot&) const;
+
void put(ExecState*, PropertyName, JSValue, PutPropertySlot&);
- void putToPrimitive(ExecState*, PropertyName, JSValue, PutPropertySlot&);
- void putToPrimitiveByIndex(ExecState*, unsigned propertyName, JSValue, bool shouldThrow);
+ JS_EXPORT_PRIVATE void putToPrimitive(ExecState*, PropertyName, JSValue, PutPropertySlot&);
+ JS_EXPORT_PRIVATE void putToPrimitiveByIndex(ExecState*, unsigned propertyName, JSValue, bool shouldThrow);
void putByIndex(ExecState*, unsigned propertyName, JSValue, bool shouldThrow);
JSValue toThis(ExecState*, ECMAMode) const;
JS_EXPORT_PRIVATE void dump(PrintStream&) const;
void dumpInContext(PrintStream&, DumpContext*) const;
+ void dumpInContextAssumingStructure(PrintStream&, DumpContext*, Structure*) const;
void dumpForBacktrace(PrintStream&) const;
JS_EXPORT_PRIVATE JSObject* synthesizePrototype(ExecState*) const;
+ bool requireObjectCoercible(ExecState*) const;
// Constants used for Int52. Int52 isn't part of JSValue right now, but JSValues may be
// converted to Int52s and back again.
};
#endif
-typedef HashMap<EncodedJSValue, unsigned, EncodedJSValueHash, EncodedJSValueHashTraits> JSValueMap;
+typedef std::pair<EncodedJSValue, SourceCodeRepresentation> EncodedJSValueWithRepresentation;
+
+struct EncodedJSValueWithRepresentationHashTraits : HashTraits<EncodedJSValueWithRepresentation> {
+ static const bool emptyValueIsZero = false;
+ static EncodedJSValueWithRepresentation emptyValue() { return std::make_pair(JSValue::encode(JSValue()), SourceCodeRepresentation::Other); }
+ static void constructDeletedValue(EncodedJSValueWithRepresentation& slot) { slot = std::make_pair(JSValue::encode(JSValue(JSValue::HashTableDeletedValue)), SourceCodeRepresentation::Other); }
+ static bool isDeletedValue(EncodedJSValueWithRepresentation value) { return value == std::make_pair(JSValue::encode(JSValue(JSValue::HashTableDeletedValue)), SourceCodeRepresentation::Other); }
+};
+
+struct EncodedJSValueWithRepresentationHash {
+ static unsigned hash(const EncodedJSValueWithRepresentation& value)
+ {
+ return WTF::pairIntHash(EncodedJSValueHash::hash(value.first), IntHash<SourceCodeRepresentation>::hash(value.second));
+ }
+ static bool equal(const EncodedJSValueWithRepresentation& a, const EncodedJSValueWithRepresentation& b)
+ {
+ return a == b;
+ }
+ static const bool safeToCompareToEmptyOrDeleted = true;
+};
// Stand-alone helper functions.
inline JSValue jsNull()
return JSValue(d);
}
+ALWAYS_INLINE JSValue jsNumber(MediaTime t)
+{
+ return jsNumber(t.toDouble());
+}
+
ALWAYS_INLINE JSValue jsNumber(char i)
{
return JSValue(i);