SpeculatedType speculationFromClassInfo(const ClassInfo* classInfo) { if (classInfo == JSFinalObject::info()) return SpecFinalObject; if (classInfo == JSArray::info()) return SpecArray; if (classInfo == Arguments::info()) return SpecArguments; if (classInfo == StringObject::info()) return SpecStringObject; if (classInfo->isSubClassOf(JSFunction::info())) return SpecFunction; if (isTypedView(classInfo->typedArrayStorageType)) return speculationFromTypedArrayType(classInfo->typedArrayStorageType); if (classInfo->isSubClassOf(JSObject::info())) return SpecObjectOther; return SpecCellOther; }
EncodedJSValue JSC_HOST_CALL typedArrayViewPrivateFuncGetOriginalConstructor(ExecState* exec) { JSGlobalObject* globalObject = exec->lexicalGlobalObject(); TypedArrayType type = exec->uncheckedArgument(0).getObject()->classInfo()->typedArrayStorageType; ASSERT(isTypedView(type)); return JSValue::encode(globalObject->typedArrayConstructor(type)); }
inline bool GetByIdVariant::canMergeIntrinsicStructures(const GetByIdVariant& other) const { if (m_intrinsicFunction != other.m_intrinsicFunction) return false; switch (intrinsic()) { case TypedArrayByteLengthIntrinsic: { // We can merge these sets as long as the element size of the two sets is the same. TypedArrayType thisType = (*m_structureSet.begin())->classInfo()->typedArrayStorageType; TypedArrayType otherType = (*other.m_structureSet.begin())->classInfo()->typedArrayStorageType; ASSERT(isTypedView(thisType) && isTypedView(otherType)); return logElementSize(thisType) == logElementSize(otherType); } default: return true; } RELEASE_ASSERT_NOT_REACHED(); }
EncodedJSValue JSC_HOST_CALL typedArrayViewPrivateFuncLength(ExecState* exec) { VM& vm = exec->vm(); auto scope = DECLARE_THROW_SCOPE(vm); JSValue argument = exec->argument(0); if (!argument.isCell() || !isTypedView(argument.asCell()->classInfo()->typedArrayStorageType)) return throwVMTypeError(exec, scope, ASCIILiteral("Receiver should be a typed array view")); JSArrayBufferView* thisObject = jsCast<JSArrayBufferView*>(argument); if (thisObject->isNeutered()) return throwVMTypeError(exec, scope, ASCIILiteral("Underlying ArrayBuffer has been detached from the view")); return JSValue::encode(jsNumber(thisObject->length())); }
bool AccessCase::canEmitIntrinsicGetter(JSFunction* getter, Structure* structure) { switch (getter->intrinsic()) { case TypedArrayByteOffsetIntrinsic: case TypedArrayByteLengthIntrinsic: case TypedArrayLengthIntrinsic: { TypedArrayType type = structure->classInfo()->typedArrayStorageType; if (!isTypedView(type)) return false; return true; } default: return false; } RELEASE_ASSERT_NOT_REACHED(); }
EncodedJSValue JSC_HOST_CALL typedArrayViewPrivateFuncIsTypedArrayView(ExecState* exec) { JSValue value = exec->uncheckedArgument(0); return JSValue::encode(jsBoolean(value.isCell() && isTypedView(value.asCell()->classInfo()->typedArrayStorageType))); }