Ignore:
Timestamp:
Jul 24, 2013, 8:59:47 PM (12 years ago)
Author:
[email protected]
Message:

fourthTier: CodeBlock should be RefCounted
https://bugs.webkit.org/show_bug.cgi?id=115594

Reviewed by Geoffrey Garen.

This makes it possible to have the currently-being-compiled CodeBlock not be
installed in Executable, while also allowing it to point to its intended
alternative(). So long as we were using ownership and not reference counting, it
would have been difficult to have both CodeBlock::m_alternative and
Executable::m_codeBlockForBlah point to the previous CodeBlock.

I also took the opportunity to clean up a bunch of code that appears to have
rotted.

  • assembler/MacroAssemblerCodeRef.h:

(MacroAssemblerCodePtr):
(JSC::MacroAssemblerCodePtr::operator==):

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::CodeBlock):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::releaseAlternative):
(JSC::CodeBlock::setAlternative):
(CodeBlock):
(JSC::GlobalCodeBlock::GlobalCodeBlock):
(JSC::ProgramCodeBlock::ProgramCodeBlock):
(JSC::EvalCodeBlock::EvalCodeBlock):
(JSC::FunctionCodeBlock::FunctionCodeBlock):

  • heap/DFGCodeBlocks.cpp:

(JSC::DFGCodeBlocks::~DFGCodeBlocks):
(JSC::DFGCodeBlocks::jettison):
(JSC::DFGCodeBlocks::deleteUnmarkedJettisonedCodeBlocks):

  • heap/DFGCodeBlocks.h:

(DFGCodeBlocks):

  • heap/Heap.cpp:

(JSC::Heap::jettisonDFGCodeBlock):

  • heap/Heap.h:
  • jit/JITDriver.h:

(JSC::jitCompileIfAppropriate):
(JSC::jitCompileFunctionIfAppropriate):

  • runtime/Executable.cpp:

(JSC::jettisonCodeBlock):
(JSC::EvalExecutable::jitCompile):
(JSC::EvalExecutable::compileInternal):
(JSC::ProgramExecutable::jitCompile):
(JSC::ProgramExecutable::compileInternal):
(JSC::FunctionExecutable::jitCompileForCall):
(JSC::FunctionExecutable::jitCompileForConstruct):
(JSC::FunctionExecutable::produceCodeBlockFor):
(JSC::FunctionExecutable::compileForCallInternal):
(JSC::FunctionExecutable::compileForConstructInternal):

  • runtime/Executable.h:

(EvalExecutable):
(FunctionExecutable):
(JSC::FunctionExecutable::codeBlockFor):

  • runtime/ExecutionHarness.h:

(JSC::prepareForExecution):
(JSC::prepareFunctionForExecution):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jit/JITDriver.h

    r153115 r153147  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3939
    4040template<typename CodeBlockType>
    41 inline bool jitCompileIfAppropriate(ExecState* exec, OwnPtr<CodeBlockType>& codeBlock, RefPtr<JITCode>& jitCode, JITCode::JITType jitType, unsigned bytecodeIndex, JITCompilationEffort effort)
     41inline bool jitCompileIfAppropriate(ExecState* exec, CodeBlockType* codeBlock, RefPtr<JITCode>& jitCode, JITCode::JITType jitType, unsigned bytecodeIndex, JITCompilationEffort effort)
    4242{
    4343    VM& vm = exec->vm();
     
    5353    RefPtr<JITCode> oldJITCode = jitCode;
    5454   
    55     bool dfgCompiled = false;
    56     if (JITCode::isOptimizingJIT(jitType))
    57         dfgCompiled = DFG::tryCompile(exec, codeBlock.get(), jitCode, bytecodeIndex);
    58     if (dfgCompiled) {
    59         if (codeBlock->alternative())
     55    if (JITCode::isOptimizingJIT(jitType)) {
     56        if (DFG::tryCompile(exec, codeBlock, jitCode, bytecodeIndex))
    6057            codeBlock->alternative()->unlinkIncomingCalls();
    61     } else {
    62         if (codeBlock->alternative()) {
    63             codeBlock = static_pointer_cast<CodeBlockType>(codeBlock->releaseAlternative());
    64             jitCode = oldJITCode;
     58        else {
     59            ASSERT(oldJITCode == jitCode);
    6560            return false;
    6661        }
    67         jitCode = JIT::compile(&vm, codeBlock.get(), effort);
    68         if (!jitCode) {
    69             jitCode = oldJITCode;
     62    } else {
     63        RefPtr<JITCode> result = JIT::compile(&vm, codeBlock, effort);
     64        if (result)
     65            jitCode = result;
     66        else
    7067            return false;
    71         }
    7268    }
     69   
    7370    codeBlock->setJITCode(jitCode, MacroAssemblerCodePtr());
    7471   
     
    7673}
    7774
    78 inline bool jitCompileFunctionIfAppropriate(ExecState* exec, OwnPtr<FunctionCodeBlock>& codeBlock, RefPtr<JITCode>& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, JITCode::JITType jitType, unsigned bytecodeIndex, JITCompilationEffort effort)
     75inline bool jitCompileFunctionIfAppropriate(ExecState* exec, FunctionCodeBlock* codeBlock, RefPtr<JITCode>& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, JITCode::JITType jitType, unsigned bytecodeIndex, JITCompilationEffort effort)
    7976{
    8077    VM& vm = exec->vm();
     
    9188    MacroAssemblerCodePtr oldJITCodeWithArityCheck = jitCodeWithArityCheck;
    9289   
    93     bool dfgCompiled = false;
    94     if (JITCode::isOptimizingJIT(jitType))
    95         dfgCompiled = DFG::tryCompileFunction(exec, codeBlock.get(), jitCode, jitCodeWithArityCheck, bytecodeIndex);
    96     if (dfgCompiled) {
    97         if (codeBlock->alternative())
     90    if (JITCode::isOptimizingJIT(jitType)) {
     91        if (DFG::tryCompileFunction(exec, codeBlock, jitCode, jitCodeWithArityCheck, bytecodeIndex))
    9892            codeBlock->alternative()->unlinkIncomingCalls();
    99     } else {
    100         if (codeBlock->alternative()) {
    101             codeBlock = static_pointer_cast<FunctionCodeBlock>(codeBlock->releaseAlternative());
    102             jitCode = oldJITCode;
    103             jitCodeWithArityCheck = oldJITCodeWithArityCheck;
     93        else {
     94            ASSERT(oldJITCode == jitCode);
     95            ASSERT_UNUSED(oldJITCodeWithArityCheck, oldJITCodeWithArityCheck == jitCodeWithArityCheck);
    10496            return false;
    10597        }
    106         jitCode = JIT::compile(&vm, codeBlock.get(), effort, &jitCodeWithArityCheck);
    107         if (!jitCode) {
    108             jitCode = oldJITCode;
    109             jitCodeWithArityCheck = oldJITCodeWithArityCheck;
     98    } else {
     99        RefPtr<JITCode> result =
     100            JIT::compile(&vm, codeBlock, effort, &jitCodeWithArityCheck);
     101        if (result)
     102            jitCode = result;
     103        else {
     104            ASSERT_UNUSED(oldJITCodeWithArityCheck, oldJITCodeWithArityCheck == jitCodeWithArityCheck);
    110105            return false;
    111106        }
    112107    }
     108
    113109    codeBlock->setJITCode(jitCode, jitCodeWithArityCheck);
    114110   
Note: See TracChangeset for help on using the changeset viewer.