- Revision
- 266223
- Author
- [email protected]
- Date
- 2020-08-26 22:27:16 -0700 (Wed, 26 Aug 2020)
Log Message
Use jsTypeofIsObject() in DFG AI and operationTypeOfIsObject()
https://bugs.webkit.org/show_bug.cgi?id=144457
Reviewed by Saam Barati.
Source/_javascript_Core:
This patch refactors jsTypeofIsObject(), leveraging fast path of isCallable(),
moves it to the header, and utilizes it in operationTypeOfIsObject() & DFG AI
(minding concurrency) to eliminate code duplication.
Also, removes orphaned slow_path_is_object declaration.
No behavior change, `typeof` microbenchmarks are neutral.
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
* dfg/DFGOperations.cpp:
* runtime/CommonSlowPaths.h:
* runtime/Operations.cpp:
(JSC::jsTypeofIsObject): Deleted.
* runtime/Operations.h:
(JSC::jsTypeofIsObjectWithConcurrency):
(JSC::jsTypeofIsObject):
Source/WTF:
* wtf/TriState.h:
(WTF::invert):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (266222 => 266223)
--- trunk/Source/_javascript_Core/ChangeLog 2020-08-27 04:36:37 UTC (rev 266222)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-08-27 05:27:16 UTC (rev 266223)
@@ -1,5 +1,30 @@
2020-08-26 Alexey Shvayka <[email protected]>
+ Use jsTypeofIsObject() in DFG AI and operationTypeOfIsObject()
+ https://bugs.webkit.org/show_bug.cgi?id=144457
+
+ Reviewed by Saam Barati.
+
+ This patch refactors jsTypeofIsObject(), leveraging fast path of isCallable(),
+ moves it to the header, and utilizes it in operationTypeOfIsObject() & DFG AI
+ (minding concurrency) to eliminate code duplication.
+
+ Also, removes orphaned slow_path_is_object declaration.
+
+ No behavior change, `typeof` microbenchmarks are neutral.
+
+ * dfg/DFGAbstractInterpreterInlines.h:
+ (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
+ * dfg/DFGOperations.cpp:
+ * runtime/CommonSlowPaths.h:
+ * runtime/Operations.cpp:
+ (JSC::jsTypeofIsObject): Deleted.
+ * runtime/Operations.h:
+ (JSC::jsTypeofIsObjectWithConcurrency):
+ (JSC::jsTypeofIsObject):
+
+2020-08-26 Alexey Shvayka <[email protected]>
+
Merge putLength() into setLength()
https://bugs.webkit.org/show_bug.cgi?id=211279
Modified: trunk/Source/_javascript_Core/dfg/DFGAbstractInterpreterInlines.h (266222 => 266223)
--- trunk/Source/_javascript_Core/dfg/DFGAbstractInterpreterInlines.h 2020-08-27 04:36:37 UTC (rev 266222)
+++ trunk/Source/_javascript_Core/dfg/DFGAbstractInterpreterInlines.h 2020-08-27 05:27:16 UTC (rev 266223)
@@ -1476,21 +1476,14 @@
? child.value().asCell()->structure(m_vm)->masqueradesAsUndefined(m_codeBlock->globalObjectFor(node->origin.semantic))
: child.value().isUndefined()));
break;
- case TypeOfIsObject:
- if (child.value().isObject()) {
- JSObject* object = asObject(child.value());
- if (object->type() == JSFunctionType)
- setConstant(node, jsBoolean(false));
- else if (!(object->inlineTypeFlags() & OverridesGetCallData))
- setConstant(node, jsBoolean(!child.value().asCell()->structure(m_vm)->masqueradesAsUndefined(m_codeBlock->globalObjectFor(node->origin.semantic))));
- else {
- // FIXME: This could just call getCallData.
- // https://bugs.webkit.org/show_bug.cgi?id=144457
- constantWasSet = false;
- }
- } else
- setConstant(node, jsBoolean(child.value().isNull()));
+ case TypeOfIsObject: {
+ TriState result = jsTypeofIsObjectWithConcurrency<Concurrency::ConcurrentThread>(m_codeBlock->globalObjectFor(node->origin.semantic), child.value());
+ if (result != TriState::Indeterminate)
+ setConstant(node, jsBoolean(result == TriState::True));
+ else
+ constantWasSet = false;
break;
+ }
case TypeOfIsFunction: {
TriState result = jsTypeofIsFunctionWithConcurrency<Concurrency::ConcurrentThread>(m_codeBlock->globalObjectFor(node->origin.semantic), child.value());
if (result != TriState::Indeterminate)
Modified: trunk/Source/_javascript_Core/dfg/DFGOperations.cpp (266222 => 266223)
--- trunk/Source/_javascript_Core/dfg/DFGOperations.cpp 2020-08-27 04:36:37 UTC (rev 266222)
+++ trunk/Source/_javascript_Core/dfg/DFGOperations.cpp 2020-08-27 05:27:16 UTC (rev 266223)
@@ -2132,11 +2132,7 @@
ASSERT(jsDynamicCast<JSObject*>(vm, object));
- if (object->structure(vm)->masqueradesAsUndefined(globalObject))
- return false;
- if (object->isCallable(vm))
- return false;
- return true;
+ return jsTypeofIsObject(globalObject, object);
}
size_t JIT_OPERATION operationTypeOfIsFunction(JSGlobalObject* globalObject, JSCell* object)
Modified: trunk/Source/_javascript_Core/runtime/CommonSlowPaths.h (266222 => 266223)
--- trunk/Source/_javascript_Core/runtime/CommonSlowPaths.h 2020-08-27 04:36:37 UTC (rev 266222)
+++ trunk/Source/_javascript_Core/runtime/CommonSlowPaths.h 2020-08-27 05:27:16 UTC (rev 266223)
@@ -253,7 +253,6 @@
SLOW_PATH_HIDDEN_DECL(slow_path_typeof);
SLOW_PATH_HIDDEN_DECL(slow_path_typeof_is_object);
SLOW_PATH_HIDDEN_DECL(slow_path_typeof_is_function);
-SLOW_PATH_HIDDEN_DECL(slow_path_is_object);
SLOW_PATH_HIDDEN_DECL(slow_path_is_callable);
SLOW_PATH_HIDDEN_DECL(slow_path_is_constructor);
SLOW_PATH_HIDDEN_DECL(slow_path_in_by_id);
Modified: trunk/Source/_javascript_Core/runtime/Operations.cpp (266222 => 266223)
--- trunk/Source/_javascript_Core/runtime/Operations.cpp 2020-08-27 04:36:37 UTC (rev 266222)
+++ trunk/Source/_javascript_Core/runtime/Operations.cpp 2020-08-27 05:27:16 UTC (rev 266223)
@@ -113,25 +113,6 @@
return vm.smallStrings.objectString();
}
-bool jsTypeofIsObject(JSGlobalObject* globalObject, JSValue v)
-{
- VM& vm = globalObject->vm();
- if (!v.isCell())
- return v.isNull();
-
- JSType type = v.asCell()->type();
- if (type == StringType || type == SymbolType || type == HeapBigIntType)
- return false;
- if (type >= ObjectType) {
- if (asObject(v)->structure(vm)->masqueradesAsUndefined(globalObject))
- return false;
- JSObject* object = asObject(v);
- if (object->isCallable(vm))
- return false;
- }
- return true;
-}
-
size_t normalizePrototypeChain(JSGlobalObject* globalObject, JSCell* base, bool& sawPolyProto)
{
VM& vm = globalObject->vm();
Modified: trunk/Source/_javascript_Core/runtime/Operations.h (266222 => 266223)
--- trunk/Source/_javascript_Core/runtime/Operations.h 2020-08-27 04:36:37 UTC (rev 266222)
+++ trunk/Source/_javascript_Core/runtime/Operations.h 2020-08-27 05:27:16 UTC (rev 266223)
@@ -32,10 +32,21 @@
NEVER_INLINE JSValue jsAddSlowCase(JSGlobalObject*, JSValue, JSValue);
JSString* jsTypeStringForValueWithConcurrency(VM&, JSGlobalObject*, JSValue, Concurrency);
-bool jsTypeofIsObject(JSGlobalObject*, JSValue);
size_t normalizePrototypeChain(JSGlobalObject*, JSCell*, bool& sawPolyProto);
template<Concurrency concurrency>
+ALWAYS_INLINE TriState jsTypeofIsObjectWithConcurrency(JSGlobalObject* globalObject, JSValue value)
+{
+ VM& vm = globalObject->vm();
+ if (!value.isObject())
+ return triState(value.isNull());
+ JSObject* object = asObject(value);
+ if (object->structure(vm)->masqueradesAsUndefined(globalObject))
+ return TriState::False;
+ return invert(object->isCallableWithConcurrency<concurrency>(vm));
+}
+
+template<Concurrency concurrency>
ALWAYS_INLINE TriState jsTypeofIsFunctionWithConcurrency(JSGlobalObject* globalObject, JSValue value)
{
VM& vm = globalObject->vm();
@@ -52,6 +63,13 @@
return jsTypeStringForValueWithConcurrency(getVM(globalObject), globalObject, value, Concurrency::MainThread);
}
+ALWAYS_INLINE bool jsTypeofIsObject(JSGlobalObject* globalObject, JSValue value)
+{
+ auto result = jsTypeofIsObjectWithConcurrency<Concurrency::MainThread>(globalObject, value);
+ ASSERT(result != TriState::Indeterminate);
+ return result == TriState::True;
+}
+
ALWAYS_INLINE bool jsTypeofIsFunction(JSGlobalObject* globalObject, JSValue value)
{
auto result = jsTypeofIsFunctionWithConcurrency<Concurrency::MainThread>(globalObject, value);
Modified: trunk/Source/WTF/ChangeLog (266222 => 266223)
--- trunk/Source/WTF/ChangeLog 2020-08-27 04:36:37 UTC (rev 266222)
+++ trunk/Source/WTF/ChangeLog 2020-08-27 05:27:16 UTC (rev 266223)
@@ -1,3 +1,13 @@
+2020-08-26 Alexey Shvayka <[email protected]>
+
+ Use jsTypeofIsObject() in DFG AI and operationTypeOfIsObject()
+ https://bugs.webkit.org/show_bug.cgi?id=144457
+
+ Reviewed by Saam Barati.
+
+ * wtf/TriState.h:
+ (WTF::invert):
+
2020-08-25 Ryosuke Niwa <[email protected]>
HashMap<Ref<T>>::take should return RefPtr<T>
Modified: trunk/Source/WTF/wtf/TriState.h (266222 => 266223)
--- trunk/Source/WTF/wtf/TriState.h 2020-08-27 04:36:37 UTC (rev 266222)
+++ trunk/Source/WTF/wtf/TriState.h 2020-08-27 05:27:16 UTC (rev 266223)
@@ -38,7 +38,17 @@
return static_cast<TriState>(boolean);
}
+inline TriState invert(TriState triState)
+{
+ if (triState == TriState::True)
+ return TriState::False;
+ if (triState == TriState::False)
+ return TriState::True;
+ return TriState::Indeterminate;
}
+}
+
using WTF::TriState;
using WTF::triState;
+using WTF::invert;