diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/dfg/DFGLazyJSValue.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/dfg/DFGLazyJSValue.h')
-rw-r--r-- | Source/JavaScriptCore/dfg/DFGLazyJSValue.h | 78 |
1 files changed, 38 insertions, 40 deletions
diff --git a/Source/JavaScriptCore/dfg/DFGLazyJSValue.h b/Source/JavaScriptCore/dfg/DFGLazyJSValue.h index 37a07266d..18bb5960f 100644 --- a/Source/JavaScriptCore/dfg/DFGLazyJSValue.h +++ b/Source/JavaScriptCore/dfg/DFGLazyJSValue.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013, 2014, 2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,33 +23,38 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef DFGLazyJSValue_h -#define DFGLazyJSValue_h - -#include <wtf/Platform.h> +#pragma once #if ENABLE(DFG_JIT) -#include "JSCJSValue.h" +#include "DFGCommon.h" +#include "DFGFrozenValue.h" #include <wtf/text/StringImpl.h> -namespace JSC { namespace DFG { +namespace JSC { + +class CCallHelpers; + +namespace DFG { + +class Graph; // Represents either a JSValue, or for JSValues that require allocation in the heap, // it tells you everything you'd need to know in order to allocate it. -enum LazinessKind { - KnownValue, - SingleCharacterString, - KnownStringImpl -}; - class LazyJSValue { public: - LazyJSValue(JSValue value = JSValue()) + enum LazinessKind { + KnownValue, + SingleCharacterString, + KnownStringImpl, + NewStringImpl + }; + + LazyJSValue(FrozenValue* value = FrozenValue::emptySingleton()) : m_kind(KnownValue) { - u.value = JSValue::encode(value); + u.value = value; } static LazyJSValue singleCharacterString(UChar character) @@ -67,20 +72,24 @@ public: result.u.stringImpl = string; return result; } + + static LazyJSValue newString(Graph&, const String&); + + LazinessKind kind() const { return m_kind; } - JSValue tryGetValue() const + FrozenValue* tryGetValue(Graph&) const { if (m_kind == KnownValue) return value(); - return JSValue(); + return nullptr; } JSValue getValue(VM&) const; - JSValue value() const + FrozenValue* value() const { ASSERT(m_kind == KnownValue); - return JSValue::decode(u.value); + return u.value; } UChar character() const @@ -88,37 +97,29 @@ public: ASSERT(m_kind == SingleCharacterString); return u.character; } + + const StringImpl* tryGetStringImpl(VM&) const; + + String tryGetString(Graph&) const; StringImpl* stringImpl() const { - ASSERT(m_kind == KnownStringImpl); + ASSERT(m_kind == KnownStringImpl || m_kind == NewStringImpl); return u.stringImpl; } - + TriState strictEqual(const LazyJSValue& other) const; - unsigned switchLookupValue() const - { - // NB. Not every kind of JSValue will be able to give you a switch lookup - // value, and this method will assert, or do bad things, if you use it - // for a kind of value that can't. - switch (m_kind) { - case KnownValue: - return value().asInt32(); - case SingleCharacterString: - return character(); - default: - RELEASE_ASSERT_NOT_REACHED(); - return 0; - } - } + uintptr_t switchLookupValue(SwitchKind) const; + + void emit(CCallHelpers&, JSValueRegs) const; void dump(PrintStream&) const; void dumpInContext(PrintStream&, DumpContext*) const; private: union { - EncodedJSValue value; + FrozenValue* value; UChar character; StringImpl* stringImpl; } u; @@ -128,6 +129,3 @@ private: } } // namespace JSC::DFG #endif // ENABLE(DFG_JIT) - -#endif // DFGLazyJSValue_h - |