/*
 * Copyright (C) 2018 Apple Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

#pragma once

#include "CodeOrigin.h"
#include "ExitingInlineKind.h"
#include <wtf/HashMap.h>

namespace JSC {

class CallLinkInfo;
class CallLinkStatus;
class CodeBlock;
class GetByStatus;
class InByIdStatus;
class PutByIdStatus;
class DeleteByStatus;
class StructureStubInfo;
struct ByValInfo;

struct ICStatus {
    StructureStubInfo* stubInfo { nullptr };
    CallLinkInfo* callLinkInfo { nullptr };
    ByValInfo* byValInfo { nullptr };
    CallLinkStatus* callStatus { nullptr };
    GetByStatus* getStatus { nullptr };
    InByIdStatus* inStatus { nullptr };
    PutByIdStatus* putStatus { nullptr };
    DeleteByStatus* deleteStatus { nullptr };
};

typedef HashMap<CodeOrigin, ICStatus, CodeOriginApproximateHash> ICStatusMap;

struct ICStatusContext {
    ICStatus get(CodeOrigin) const;
    bool isInlined(CodeOrigin) const;
    ExitingInlineKind inlineKind(CodeOrigin) const;
    
    InlineCallFrame* inlineCallFrame { nullptr };
    CodeBlock* optimizedCodeBlock { nullptr };
    ICStatusMap map;
};

typedef Vector<ICStatusContext*, 8> ICStatusContextStack;

} // namespace JSC

