Changeset 266223 in webkit for trunk/Source/JavaScriptCore
- Timestamp:
- Aug 26, 2020, 10:27:16 PM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r266215 r266223 1 2020-08-26 Alexey Shvayka <[email protected]> 2 3 Use jsTypeofIsObject() in DFG AI and operationTypeOfIsObject() 4 https://bugs.webkit.org/show_bug.cgi?id=144457 5 6 Reviewed by Saam Barati. 7 8 This patch refactors jsTypeofIsObject(), leveraging fast path of isCallable(), 9 moves it to the header, and utilizes it in operationTypeOfIsObject() & DFG AI 10 (minding concurrency) to eliminate code duplication. 11 12 Also, removes orphaned slow_path_is_object declaration. 13 14 No behavior change, `typeof` microbenchmarks are neutral. 15 16 * dfg/DFGAbstractInterpreterInlines.h: 17 (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): 18 * dfg/DFGOperations.cpp: 19 * runtime/CommonSlowPaths.h: 20 * runtime/Operations.cpp: 21 (JSC::jsTypeofIsObject): Deleted. 22 * runtime/Operations.h: 23 (JSC::jsTypeofIsObjectWithConcurrency): 24 (JSC::jsTypeofIsObject): 25 1 26 2020-08-26 Alexey Shvayka <[email protected]> 2 27 -
trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h
r266107 r266223 1477 1477 : child.value().isUndefined())); 1478 1478 break; 1479 case TypeOfIsObject: 1480 if (child.value().isObject()) { 1481 JSObject* object = asObject(child.value()); 1482 if (object->type() == JSFunctionType) 1483 setConstant(node, jsBoolean(false)); 1484 else if (!(object->inlineTypeFlags() & OverridesGetCallData)) 1485 setConstant(node, jsBoolean(!child.value().asCell()->structure(m_vm)->masqueradesAsUndefined(m_codeBlock->globalObjectFor(node->origin.semantic)))); 1486 else { 1487 // FIXME: This could just call getCallData. 1488 // https://bugs.webkit.org/show_bug.cgi?id=144457 1489 constantWasSet = false; 1490 } 1491 } else 1492 setConstant(node, jsBoolean(child.value().isNull())); 1493 break; 1479 case TypeOfIsObject: { 1480 TriState result = jsTypeofIsObjectWithConcurrency<Concurrency::ConcurrentThread>(m_codeBlock->globalObjectFor(node->origin.semantic), child.value()); 1481 if (result != TriState::Indeterminate) 1482 setConstant(node, jsBoolean(result == TriState::True)); 1483 else 1484 constantWasSet = false; 1485 break; 1486 } 1494 1487 case TypeOfIsFunction: { 1495 1488 TriState result = jsTypeofIsFunctionWithConcurrency<Concurrency::ConcurrentThread>(m_codeBlock->globalObjectFor(node->origin.semantic), child.value()); -
trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp
r266019 r266223 2133 2133 ASSERT(jsDynamicCast<JSObject*>(vm, object)); 2134 2134 2135 if (object->structure(vm)->masqueradesAsUndefined(globalObject)) 2136 return false; 2137 if (object->isCallable(vm)) 2138 return false; 2139 return true; 2135 return jsTypeofIsObject(globalObject, object); 2140 2136 } 2141 2137 -
trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.h
r266019 r266223 254 254 SLOW_PATH_HIDDEN_DECL(slow_path_typeof_is_object); 255 255 SLOW_PATH_HIDDEN_DECL(slow_path_typeof_is_function); 256 SLOW_PATH_HIDDEN_DECL(slow_path_is_object);257 256 SLOW_PATH_HIDDEN_DECL(slow_path_is_callable); 258 257 SLOW_PATH_HIDDEN_DECL(slow_path_is_constructor); -
trunk/Source/JavaScriptCore/runtime/Operations.cpp
r266107 r266223 114 114 } 115 115 116 bool jsTypeofIsObject(JSGlobalObject* globalObject, JSValue v)117 {118 VM& vm = globalObject->vm();119 if (!v.isCell())120 return v.isNull();121 122 JSType type = v.asCell()->type();123 if (type == StringType || type == SymbolType || type == HeapBigIntType)124 return false;125 if (type >= ObjectType) {126 if (asObject(v)->structure(vm)->masqueradesAsUndefined(globalObject))127 return false;128 JSObject* object = asObject(v);129 if (object->isCallable(vm))130 return false;131 }132 return true;133 }134 135 116 size_t normalizePrototypeChain(JSGlobalObject* globalObject, JSCell* base, bool& sawPolyProto) 136 117 { -
trunk/Source/JavaScriptCore/runtime/Operations.h
r266107 r266223 33 33 NEVER_INLINE JSValue jsAddSlowCase(JSGlobalObject*, JSValue, JSValue); 34 34 JSString* jsTypeStringForValueWithConcurrency(VM&, JSGlobalObject*, JSValue, Concurrency); 35 bool jsTypeofIsObject(JSGlobalObject*, JSValue);36 35 size_t normalizePrototypeChain(JSGlobalObject*, JSCell*, bool& sawPolyProto); 36 37 template<Concurrency concurrency> 38 ALWAYS_INLINE TriState jsTypeofIsObjectWithConcurrency(JSGlobalObject* globalObject, JSValue value) 39 { 40 VM& vm = globalObject->vm(); 41 if (!value.isObject()) 42 return triState(value.isNull()); 43 JSObject* object = asObject(value); 44 if (object->structure(vm)->masqueradesAsUndefined(globalObject)) 45 return TriState::False; 46 return invert(object->isCallableWithConcurrency<concurrency>(vm)); 47 } 37 48 38 49 template<Concurrency concurrency> … … 51 62 { 52 63 return jsTypeStringForValueWithConcurrency(getVM(globalObject), globalObject, value, Concurrency::MainThread); 64 } 65 66 ALWAYS_INLINE bool jsTypeofIsObject(JSGlobalObject* globalObject, JSValue value) 67 { 68 auto result = jsTypeofIsObjectWithConcurrency<Concurrency::MainThread>(globalObject, value); 69 ASSERT(result != TriState::Indeterminate); 70 return result == TriState::True; 53 71 } 54 72
Note:
See TracChangeset
for help on using the changeset viewer.