Changeset 47412 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Aug 17, 2009, 10:34:52 PM (16 years ago)
Author:
[email protected]
Message:

No, silly runtime, AST nodes are not for you.

Reviewed by Sam Weinig.

We still use AST nodes (ScopeNodes, particularly FunctionBodyNodes) within
the runtime, which means that these nodes must be persisted outside of the
arena, contain both parser & runtime data, etc. This is all a bit of a mess.

Move functionality into a new FunctionExecutable class.

(JSC::CodeBlock::CodeBlock):
(JSC::CodeBlock::markAggregate):
(JSC::CodeBlock::reparseForExceptionInfoIfNecessary):
(JSC::CodeBlock::lineNumberForBytecodeOffset):
(JSC::CodeBlock::shrinkToFit):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::getBytecodeIndex):
(JSC::CodeBlock::discardBytecode):
(JSC::CodeBlock::instructionCount):
(JSC::CodeBlock::getJITCode):
(JSC::CodeBlock::executablePool):
(JSC::CodeBlock::ownerExecutable):
(JSC::CodeBlock::extractExceptionInfo):
(JSC::CodeBlock::addFunctionDecl):
(JSC::CodeBlock::functionDecl):
(JSC::CodeBlock::numberOfFunctionDecls):
(JSC::CodeBlock::addFunctionExpr):
(JSC::CodeBlock::functionExpr):
(JSC::GlobalCodeBlock::GlobalCodeBlock):
(JSC::ProgramCodeBlock::ProgramCodeBlock):
(JSC::EvalCodeBlock::EvalCodeBlock):
(JSC::FunctionCodeBlock::FunctionCodeBlock):
(JSC::NativeCodeBlock::NativeCodeBlock):

  • bytecode/EvalCodeCache.h:
  • bytecode/SamplingTool.cpp:

(JSC::SamplingTool::doRun):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::emitNewFunction):
(JSC::BytecodeGenerator::emitNewFunctionExpression):

  • bytecompiler/BytecodeGenerator.h:
  • debugger/Debugger.cpp:

(JSC::Debugger::recompileAllJSFunctions):

  • interpreter/CachedCall.h:

(JSC::CachedCall::CachedCall):

  • interpreter/CallFrameClosure.h:
  • interpreter/Interpreter.cpp:

(JSC::Interpreter::unwindCallFrame):
(JSC::Interpreter::throwException):
(JSC::Interpreter::execute):
(JSC::Interpreter::prepareForRepeatCall):
(JSC::Interpreter::debug):
(JSC::Interpreter::privateExecute):
(JSC::Interpreter::retrieveLastCaller):

  • interpreter/Interpreter.h:
  • jit/JIT.cpp:

(JSC::JIT::privateCompile):

  • jit/JIT.h:

(JSC::JIT::compile):

  • jit/JITOpcodes.cpp:

(JSC::JIT::privateCompileCTIMachineTrampolines):
(JSC::JIT::emit_op_new_func):
(JSC::JIT::emit_op_new_func_exp):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • jit/JITStubs.h:

(JSC::):

  • parser/Nodes.cpp:

(JSC::FunctionBodyNode::reparseDataIfNecessary):

  • parser/Nodes.h:

(JSC::EvalNode::partialDestroyData):

  • parser/Parser.h:
  • profiler/ProfileGenerator.cpp:
  • profiler/Profiler.cpp:

(JSC::Profiler::createCallIdentifier):
(JSC::createCallIdentifierFromFunctionImp):

  • runtime/Arguments.h:

(JSC::Arguments::getArgumentsData):
(JSC::Arguments::Arguments):
(JSC::JSActivation::copyRegisters):

  • runtime/ArrayPrototype.cpp:

(JSC::isNumericCompareFunction):

  • runtime/CallData.h:

(JSC::):

  • runtime/Collector.cpp:

(JSC::Heap::collect):

  • runtime/ConstructData.h:

(JSC::):

  • runtime/ExceptionHelpers.cpp:

(JSC::createUndefinedVariableError):
(JSC::createInvalidParamError):
(JSC::createNotAConstructorError):
(JSC::createNotAFunctionError):
(JSC::createNotAnObjectError):

  • runtime/Executable.cpp: Added.

(JSC::EvalExecutable::generateBytecode):
(JSC::ProgramExecutable::generateBytecode):
(JSC::FunctionExecutable::generateBytecode):
(JSC::EvalExecutable::generateJITCode):
(JSC::ProgramExecutable::generateJITCode):
(JSC::FunctionExecutable::generateJITCode):
(JSC::FunctionExecutable::isHostFunction):
(JSC::FunctionExecutable::markAggregate):
(JSC::FunctionExecutable::reparseExceptionInfo):
(JSC::EvalExecutable::reparseExceptionInfo):
(JSC::FunctionExecutable::recompile):
(JSC::FunctionExecutable::FunctionExecutable):

  • runtime/Executable.h:

(JSC::ExecutableBase::~ExecutableBase):
(JSC::ExecutableBase::ExecutableBase):
(JSC::ExecutableBase::source):
(JSC::ExecutableBase::sourceID):
(JSC::ExecutableBase::lastLine):
(JSC::ExecutableBase::usesEval):
(JSC::ExecutableBase::usesArguments):
(JSC::ExecutableBase::needsActivation):
(JSC::ExecutableBase::astNode):
(JSC::ExecutableBase::generatedJITCode):
(JSC::ExecutableBase::getExecutablePool):
(JSC::EvalExecutable::EvalExecutable):
(JSC::EvalExecutable::bytecode):
(JSC::EvalExecutable::varStack):
(JSC::EvalExecutable::evalNode):
(JSC::EvalExecutable::jitCode):
(JSC::ProgramExecutable::ProgramExecutable):
(JSC::ProgramExecutable::reparseExceptionInfo):
(JSC::ProgramExecutable::bytecode):
(JSC::ProgramExecutable::programNode):
(JSC::ProgramExecutable::jitCode):
(JSC::FunctionExecutable::FunctionExecutable):
(JSC::FunctionExecutable::name):
(JSC::FunctionExecutable::bytecode):
(JSC::FunctionExecutable::generatedBytecode):
(JSC::FunctionExecutable::usesEval):
(JSC::FunctionExecutable::usesArguments):
(JSC::FunctionExecutable::parameterCount):
(JSC::FunctionExecutable::paramString):
(JSC::FunctionExecutable::isGenerated):
(JSC::FunctionExecutable::body):
(JSC::FunctionExecutable::jitCode):
(JSC::FunctionExecutable::createNativeThunk):

  • runtime/FunctionConstructor.cpp:

(JSC::constructFunction):

  • runtime/FunctionPrototype.cpp:

(JSC::functionProtoFuncToString):

  • runtime/JSActivation.cpp:

(JSC::JSActivation::JSActivation):
(JSC::JSActivation::markChildren):
(JSC::JSActivation::isDynamicScope):
(JSC::JSActivation::argumentsGetter):

  • runtime/JSActivation.h:

(JSC::JSActivation::JSActivationData::JSActivationData):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::isHostFunction):
(JSC::JSFunction::JSFunction):
(JSC::JSFunction::~JSFunction):
(JSC::JSFunction::markChildren):
(JSC::JSFunction::getCallData):
(JSC::JSFunction::call):
(JSC::JSFunction::lengthGetter):
(JSC::JSFunction::getConstructData):
(JSC::JSFunction::construct):

  • runtime/JSFunction.h:

(JSC::JSFunction::executable):
(JSC::FunctionExecutable::make):

  • runtime/JSGlobalData.cpp:

(JSC::JSGlobalData::JSGlobalData):
(JSC::JSGlobalData::numericCompareFunction):

  • runtime/JSGlobalData.h:
Location:
trunk/JavaScriptCore
Files:
1 added
41 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSCallbackFunction.cpp

    r43160 r47412  
    2929
    3030#include "APICast.h"
     31#include "CodeBlock.h"
    3132#include "JSFunction.h"
    3233#include "FunctionPrototype.h"
  • trunk/JavaScriptCore/API/JSObjectRef.cpp

    r46431 r47412  
    2929
    3030#include "APICast.h"
     31#include "CodeBlock.h"
    3132#include "DateConstructor.h"
    3233#include "ErrorConstructor.h"
  • trunk/JavaScriptCore/ChangeLog

    r47405 r47412  
     12009-08-17  Gavin Barraclough  <[email protected]>
     2
     3        Reviewed by Sam Weinig.
     4
     5        No, silly runtime, AST nodes are not for you.
     6
     7        We still use AST nodes (ScopeNodes, particularly FunctionBodyNodes) within
     8        the runtime, which means that these nodes must be persisted outside of the
     9        arena, contain both parser & runtime data, etc.  This is all a bit of a mess.
     10
     11        Move functionality into a new FunctionExecutable class.
     12
     13        * API/JSCallbackFunction.cpp:
     14        * API/JSObjectRef.cpp:
     15        * JavaScriptCore.exp:
     16        * JavaScriptCore.xcodeproj/project.pbxproj:
     17        * bytecode/CodeBlock.cpp:
     18        (JSC::CodeBlock::CodeBlock):
     19        (JSC::CodeBlock::markAggregate):
     20        (JSC::CodeBlock::reparseForExceptionInfoIfNecessary):
     21        (JSC::CodeBlock::lineNumberForBytecodeOffset):
     22        (JSC::CodeBlock::shrinkToFit):
     23        * bytecode/CodeBlock.h:
     24        (JSC::CodeBlock::getBytecodeIndex):
     25        (JSC::CodeBlock::discardBytecode):
     26        (JSC::CodeBlock::instructionCount):
     27        (JSC::CodeBlock::getJITCode):
     28        (JSC::CodeBlock::executablePool):
     29        (JSC::CodeBlock::ownerExecutable):
     30        (JSC::CodeBlock::extractExceptionInfo):
     31        (JSC::CodeBlock::addFunctionDecl):
     32        (JSC::CodeBlock::functionDecl):
     33        (JSC::CodeBlock::numberOfFunctionDecls):
     34        (JSC::CodeBlock::addFunctionExpr):
     35        (JSC::CodeBlock::functionExpr):
     36        (JSC::GlobalCodeBlock::GlobalCodeBlock):
     37        (JSC::ProgramCodeBlock::ProgramCodeBlock):
     38        (JSC::EvalCodeBlock::EvalCodeBlock):
     39        (JSC::FunctionCodeBlock::FunctionCodeBlock):
     40        (JSC::NativeCodeBlock::NativeCodeBlock):
     41        * bytecode/EvalCodeCache.h:
     42        * bytecode/SamplingTool.cpp:
     43        (JSC::SamplingTool::doRun):
     44        * bytecompiler/BytecodeGenerator.cpp:
     45        (JSC::BytecodeGenerator::BytecodeGenerator):
     46        (JSC::BytecodeGenerator::emitNewFunction):
     47        (JSC::BytecodeGenerator::emitNewFunctionExpression):
     48        * bytecompiler/BytecodeGenerator.h:
     49        * debugger/Debugger.cpp:
     50        (JSC::Debugger::recompileAllJSFunctions):
     51        * interpreter/CachedCall.h:
     52        (JSC::CachedCall::CachedCall):
     53        * interpreter/CallFrameClosure.h:
     54        * interpreter/Interpreter.cpp:
     55        (JSC::Interpreter::unwindCallFrame):
     56        (JSC::Interpreter::throwException):
     57        (JSC::Interpreter::execute):
     58        (JSC::Interpreter::prepareForRepeatCall):
     59        (JSC::Interpreter::debug):
     60        (JSC::Interpreter::privateExecute):
     61        (JSC::Interpreter::retrieveLastCaller):
     62        * interpreter/Interpreter.h:
     63        * jit/JIT.cpp:
     64        (JSC::JIT::privateCompile):
     65        * jit/JIT.h:
     66        (JSC::JIT::compile):
     67        * jit/JITOpcodes.cpp:
     68        (JSC::JIT::privateCompileCTIMachineTrampolines):
     69        (JSC::JIT::emit_op_new_func):
     70        (JSC::JIT::emit_op_new_func_exp):
     71        * jit/JITStubs.cpp:
     72        (JSC::DEFINE_STUB_FUNCTION):
     73        * jit/JITStubs.h:
     74        (JSC::):
     75        * parser/Nodes.cpp:
     76        (JSC::FunctionBodyNode::reparseDataIfNecessary):
     77        * parser/Nodes.h:
     78        (JSC::EvalNode::partialDestroyData):
     79        * parser/Parser.h:
     80        * profiler/ProfileGenerator.cpp:
     81        * profiler/Profiler.cpp:
     82        (JSC::Profiler::createCallIdentifier):
     83        (JSC::createCallIdentifierFromFunctionImp):
     84        * runtime/Arguments.h:
     85        (JSC::Arguments::getArgumentsData):
     86        (JSC::Arguments::Arguments):
     87        (JSC::JSActivation::copyRegisters):
     88        * runtime/ArrayPrototype.cpp:
     89        (JSC::isNumericCompareFunction):
     90        * runtime/CallData.h:
     91        (JSC::):
     92        * runtime/Collector.cpp:
     93        (JSC::Heap::collect):
     94        * runtime/ConstructData.h:
     95        (JSC::):
     96        * runtime/ExceptionHelpers.cpp:
     97        (JSC::createUndefinedVariableError):
     98        (JSC::createInvalidParamError):
     99        (JSC::createNotAConstructorError):
     100        (JSC::createNotAFunctionError):
     101        (JSC::createNotAnObjectError):
     102        * runtime/Executable.cpp: Added.
     103        (JSC::EvalExecutable::generateBytecode):
     104        (JSC::ProgramExecutable::generateBytecode):
     105        (JSC::FunctionExecutable::generateBytecode):
     106        (JSC::EvalExecutable::generateJITCode):
     107        (JSC::ProgramExecutable::generateJITCode):
     108        (JSC::FunctionExecutable::generateJITCode):
     109        (JSC::FunctionExecutable::isHostFunction):
     110        (JSC::FunctionExecutable::markAggregate):
     111        (JSC::FunctionExecutable::reparseExceptionInfo):
     112        (JSC::EvalExecutable::reparseExceptionInfo):
     113        (JSC::FunctionExecutable::recompile):
     114        (JSC::FunctionExecutable::FunctionExecutable):
     115        * runtime/Executable.h:
     116        (JSC::ExecutableBase::~ExecutableBase):
     117        (JSC::ExecutableBase::ExecutableBase):
     118        (JSC::ExecutableBase::source):
     119        (JSC::ExecutableBase::sourceID):
     120        (JSC::ExecutableBase::lastLine):
     121        (JSC::ExecutableBase::usesEval):
     122        (JSC::ExecutableBase::usesArguments):
     123        (JSC::ExecutableBase::needsActivation):
     124        (JSC::ExecutableBase::astNode):
     125        (JSC::ExecutableBase::generatedJITCode):
     126        (JSC::ExecutableBase::getExecutablePool):
     127        (JSC::EvalExecutable::EvalExecutable):
     128        (JSC::EvalExecutable::bytecode):
     129        (JSC::EvalExecutable::varStack):
     130        (JSC::EvalExecutable::evalNode):
     131        (JSC::EvalExecutable::jitCode):
     132        (JSC::ProgramExecutable::ProgramExecutable):
     133        (JSC::ProgramExecutable::reparseExceptionInfo):
     134        (JSC::ProgramExecutable::bytecode):
     135        (JSC::ProgramExecutable::programNode):
     136        (JSC::ProgramExecutable::jitCode):
     137        (JSC::FunctionExecutable::FunctionExecutable):
     138        (JSC::FunctionExecutable::name):
     139        (JSC::FunctionExecutable::bytecode):
     140        (JSC::FunctionExecutable::generatedBytecode):
     141        (JSC::FunctionExecutable::usesEval):
     142        (JSC::FunctionExecutable::usesArguments):
     143        (JSC::FunctionExecutable::parameterCount):
     144        (JSC::FunctionExecutable::paramString):
     145        (JSC::FunctionExecutable::isGenerated):
     146        (JSC::FunctionExecutable::body):
     147        (JSC::FunctionExecutable::jitCode):
     148        (JSC::FunctionExecutable::createNativeThunk):
     149        * runtime/FunctionConstructor.cpp:
     150        (JSC::constructFunction):
     151        * runtime/FunctionPrototype.cpp:
     152        (JSC::functionProtoFuncToString):
     153        * runtime/JSActivation.cpp:
     154        (JSC::JSActivation::JSActivation):
     155        (JSC::JSActivation::markChildren):
     156        (JSC::JSActivation::isDynamicScope):
     157        (JSC::JSActivation::argumentsGetter):
     158        * runtime/JSActivation.h:
     159        (JSC::JSActivation::JSActivationData::JSActivationData):
     160        * runtime/JSFunction.cpp:
     161        (JSC::JSFunction::isHostFunction):
     162        (JSC::JSFunction::JSFunction):
     163        (JSC::JSFunction::~JSFunction):
     164        (JSC::JSFunction::markChildren):
     165        (JSC::JSFunction::getCallData):
     166        (JSC::JSFunction::call):
     167        (JSC::JSFunction::lengthGetter):
     168        (JSC::JSFunction::getConstructData):
     169        (JSC::JSFunction::construct):
     170        * runtime/JSFunction.h:
     171        (JSC::JSFunction::executable):
     172        (JSC::FunctionExecutable::make):
     173        * runtime/JSGlobalData.cpp:
     174        (JSC::JSGlobalData::JSGlobalData):
     175        (JSC::JSGlobalData::numericCompareFunction):
     176        * runtime/JSGlobalData.h:
     177
    11782009-08-17  Mark Rowe  <[email protected]>
    2179
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r47272 r47412  
    331331__ZNK3JSC12StringObject8toStringEPNS_9ExecStateE
    332332__ZNK3JSC14JSGlobalObject14isDynamicScopeEv
    333 __ZNK3JSC16FunctionBodyNode14isHostFunctionEv
    334333__ZNK3JSC16InternalFunction9classInfoEv
    335334__ZNK3JSC16JSVariableObject16isVariableObjectEv
  • trunk/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj

    r47022 r47412  
    642642                        <File
    643643                                RelativePath="..\..\runtime\ErrorPrototype.h"
     644                                >
     645                        </File>
     646                        <File
     647                                RelativePath="..\..\runtime\Executable.cpp"
    644648                                >
    645649                        </File>
  • trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r47304 r47412  
    133133                86ADD1460FDDEA980006EEC2 /* MacroAssemblerARMv7.h in Headers */ = {isa = PBXBuildFile; fileRef = 86ADD1440FDDEA980006EEC2 /* MacroAssemblerARMv7.h */; };
    134134                86C36EEA0EE1289D00B3DF59 /* MacroAssembler.h in Headers */ = {isa = PBXBuildFile; fileRef = 86C36EE90EE1289D00B3DF59 /* MacroAssembler.h */; };
     135                86CA032E1038E8440028A609 /* Executable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86CA032D1038E8440028A609 /* Executable.cpp */; };
    135136                86CAFEE31035DDE60028A609 /* Executable.h in Headers */ = {isa = PBXBuildFile; fileRef = 86CAFEE21035DDE60028A609 /* Executable.h */; settings = {ATTRIBUTES = (Private, ); }; };
    136137                86CC85A10EE79A4700288682 /* JITInlineMethods.h in Headers */ = {isa = PBXBuildFile; fileRef = 86CC85A00EE79A4700288682 /* JITInlineMethods.h */; };
     
    648649                86ADD1440FDDEA980006EEC2 /* MacroAssemblerARMv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerARMv7.h; sourceTree = "<group>"; };
    649650                86C36EE90EE1289D00B3DF59 /* MacroAssembler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssembler.h; sourceTree = "<group>"; };
     651                86CA032D1038E8440028A609 /* Executable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Executable.cpp; sourceTree = "<group>"; };
    650652                86CAFEE21035DDE60028A609 /* Executable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Executable.h; sourceTree = "<group>"; };
    651653                86CC85A00EE79A4700288682 /* JITInlineMethods.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITInlineMethods.h; sourceTree = "<group>"; };
     
    13801382                                1429D8770ED21ACD00B89619 /* ExceptionHelpers.cpp */,
    13811383                                A72701B30DADE94900E548D7 /* ExceptionHelpers.h */,
     1384                                86CA032D1038E8440028A609 /* Executable.cpp */,
    13821385                                86CAFEE21035DDE60028A609 /* Executable.h */,
    13831386                                BC2680C00E16D4E900A06E92 /* FunctionConstructor.cpp */,
     
    22772280                                A7C530E4102A3813005BC741 /* MarkStackPosix.cpp in Sources */,
    22782281                                A74B3499102A5F8E0032AB98 /* MarkStack.cpp in Sources */,
     2282                                86CA032E1038E8440028A609 /* Executable.cpp in Sources */,
    22792283                        );
    22802284                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/JavaScriptCore/bytecode/CodeBlock.cpp

    r47089 r47412  
    12491249}
    12501250
    1251 CodeBlock::CodeBlock(ScopeNode* ownerNode)
     1251CodeBlock::CodeBlock(ExecutableBase* ownerExecutable)
    12521252    : m_numCalleeRegisters(0)
    12531253    , m_numVars(0)
    12541254    , m_numParameters(0)
    1255     , m_ownerNode(ownerNode)
     1255    , m_ownerExecutable(ownerExecutable)
    12561256    , m_globalData(0)
    12571257#ifndef NDEBUG
     
    12711271}
    12721272
    1273 CodeBlock::CodeBlock(ScopeNode* ownerNode, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)
     1273CodeBlock::CodeBlock(ExecutableBase* ownerExecutable, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)
    12741274    : m_numCalleeRegisters(0)
    12751275    , m_numVars(0)
    12761276    , m_numParameters(0)
    1277     , m_ownerNode(ownerNode)
     1277    , m_ownerExecutable(ownerExecutable)
    12781278    , m_globalData(0)
    12791279#ifndef NDEBUG
    12801280    , m_instructionCount(0)
    12811281#endif
    1282     , m_needsFullScopeChain(ownerNode->needsActivation())
    1283     , m_usesEval(ownerNode->usesEval())
     1282    , m_needsFullScopeChain(ownerExecutable->needsActivation())
     1283    , m_usesEval(ownerExecutable->usesEval())
    12841284    , m_isNumericCompareFunction(false)
    12851285    , m_codeType(codeType)
     
    14381438    }
    14391439
    1440     for (size_t i = 0; i < m_functions.size(); ++i)
    1441         m_functions[i]->markAggregate(markStack);
    1442 
    1443     if (m_rareData)
    1444         m_rareData->m_evalCodeCache.markAggregate(markStack);
     1440    for (size_t i = 0; i < m_functionExprs.size(); ++i)
     1441        m_functionExprs[i]->markAggregate(markStack);
     1442    for (size_t i = 0; i < m_functionDecls.size(); ++i)
     1443        m_functionDecls[i]->markAggregate(markStack);
    14451444}
    14461445
     
    14641463    }
    14651464
    1466     switch (m_codeType) {
    1467         case FunctionCode: {
    1468             FunctionBodyNode* ownerFunctionBodyNode = static_cast<FunctionBodyNode*>(m_ownerNode);
    1469             RefPtr<FunctionBodyNode> newFunctionBody = m_globalData->parser->reparse<FunctionBodyNode>(m_globalData, ownerFunctionBodyNode);
    1470             ASSERT(newFunctionBody);
    1471             newFunctionBody->finishParsing(ownerFunctionBodyNode->copyParameters(), ownerFunctionBodyNode->parameterCount(), ownerFunctionBodyNode->ident());
    1472 
    1473             m_globalData->scopeNodeBeingReparsed = newFunctionBody.get();
    1474 
    1475             CodeBlock& newCodeBlock = newFunctionBody->bytecodeForExceptionInfoReparse(scopeChain, this);
    1476             ASSERT(newCodeBlock.m_exceptionInfo);
    1477             ASSERT(newCodeBlock.m_instructionCount == m_instructionCount);
    1478 
    1479 #if ENABLE(JIT)
    1480             JIT::compile(m_globalData, &newCodeBlock);
    1481             ASSERT(newFunctionBody->generatedJITCode().size() == ownerNode()->generatedJITCode().size());
    1482 #endif
    1483 
    1484             m_exceptionInfo.set(newCodeBlock.m_exceptionInfo.release());
    1485 
    1486             m_globalData->scopeNodeBeingReparsed = 0;
    1487 
    1488             break;
    1489         }
    1490         case EvalCode: {
    1491             EvalNode* ownerEvalNode = static_cast<EvalNode*>(m_ownerNode);
    1492             RefPtr<EvalNode> newEvalBody = m_globalData->parser->reparse<EvalNode>(m_globalData, ownerEvalNode);
    1493 
    1494             m_globalData->scopeNodeBeingReparsed = newEvalBody.get();
    1495 
    1496             EvalCodeBlock& newCodeBlock = newEvalBody->bytecodeForExceptionInfoReparse(scopeChain, this);
    1497             ASSERT(newCodeBlock.m_exceptionInfo);
    1498             ASSERT(newCodeBlock.m_instructionCount == m_instructionCount);
    1499 
    1500 #if ENABLE(JIT)
    1501             JIT::compile(m_globalData, &newCodeBlock);
    1502             ASSERT(newEvalBody->generatedJITCode().size() == ownerNode()->generatedJITCode().size());
    1503 #endif
    1504 
    1505             m_exceptionInfo.set(newCodeBlock.m_exceptionInfo.release());
    1506 
    1507             m_globalData->scopeNodeBeingReparsed = 0;
    1508 
    1509             break;
    1510         }
    1511         default:
    1512             // CodeBlocks for Global code blocks are transient and therefore to not gain from
    1513             // from throwing out there exception information.
    1514             ASSERT_NOT_REACHED();
    1515     }
     1465    m_exceptionInfo.set(m_ownerExecutable->reparseExceptionInfo(m_globalData, scopeChain, this));
    15161466}
    15171467
     
    15441494
    15451495    if (!m_exceptionInfo->m_lineInfo.size())
    1546         return m_ownerNode->source().firstLine(); // Empty function
     1496        return m_ownerExecutable->source().firstLine(); // Empty function
    15471497
    15481498    int low = 0;
     
    15571507   
    15581508    if (!low)
    1559         return m_ownerNode->source().firstLine();
     1509        return m_ownerExecutable->source().firstLine();
    15601510    return m_exceptionInfo->m_lineInfo[low - 1].lineNumber;
    15611511}
     
    16971647        return false;
    16981648    return true;
    1699 }
    1700 #endif
    1701 
    1702 #if ENABLE(JIT)
    1703 void CodeBlock::setJITCode(JITCode jitCode)
    1704 {
    1705     ASSERT(m_codeType != NativeCode);
    1706     ownerNode()->setJITCode(jitCode);
    1707 #if !ENABLE(OPCODE_SAMPLING)
    1708     if (!BytecodeGenerator::dumpsGeneratedCode())
    1709         m_instructions.clear();
    1710 #endif
    17111649}
    17121650#endif
     
    17271665
    17281666    m_identifiers.shrinkToFit();
    1729     m_functions.shrinkToFit();
     1667    m_functionDecls.shrinkToFit();
     1668    m_functionExprs.shrinkToFit();
    17301669    m_constantRegisters.shrinkToFit();
    17311670
  • trunk/JavaScriptCore/bytecode/CodeBlock.h

    r47304 r47412  
    249249#endif
    250250
     251    struct ExceptionInfo : FastAllocBase {
     252        Vector<ExpressionRangeInfo> m_expressionInfo;
     253        Vector<LineInfo> m_lineInfo;
     254        Vector<GetByIdExceptionInfo> m_getByIdExceptionInfo;
     255
     256#if ENABLE(JIT)
     257        Vector<CallReturnOffsetToBytecodeIndex> m_callReturnIndexVector;
     258#endif
     259    };
     260
    251261    class CodeBlock : public FastAllocBase {
    252262        friend class JIT;
    253263    protected:
    254         CodeBlock(ScopeNode* ownerNode);
    255         CodeBlock(ScopeNode* ownerNode, CodeType, PassRefPtr<SourceProvider>, unsigned sourceOffset);
     264        CodeBlock(ExecutableBase* ownerExecutable);
     265        CodeBlock(ExecutableBase* ownerExecutable, CodeType, PassRefPtr<SourceProvider>, unsigned sourceOffset);
    256266    public:
    257267        ~CodeBlock();
     
    331341        {
    332342            reparseForExceptionInfoIfNecessary(callFrame);
    333             return binaryChop<CallReturnOffsetToBytecodeIndex, unsigned, getCallReturnOffset>(callReturnIndexVector().begin(), callReturnIndexVector().size(), ownerNode()->generatedJITCode().offsetOf(returnAddress.value()))->bytecodeIndex;
     343            return binaryChop<CallReturnOffsetToBytecodeIndex, unsigned, getCallReturnOffset>(callReturnIndexVector().begin(), callReturnIndexVector().size(), ownerExecutable()->generatedJITCode().offsetOf(returnAddress.value()))->bytecodeIndex;
    334344        }
    335345       
     
    341351
    342352        Vector<Instruction>& instructions() { return m_instructions; }
     353        void discardBytecode() { m_instructions.clear(); }
     354
    343355#ifndef NDEBUG
     356        unsigned instructionCount() { return m_instructionCount; }
    344357        void setInstructionCount(unsigned instructionCount) { m_instructionCount = instructionCount; }
    345358#endif
    346359
    347360#if ENABLE(JIT)
    348         JITCode& getJITCode() { return ownerNode()->generatedJITCode(); }
    349         void setJITCode(JITCode);
    350         ExecutablePool* executablePool() { return ownerNode()->getExecutablePool(); }
    351 #endif
    352 
    353         ScopeNode* ownerNode() const { return m_ownerNode; }
     361        JITCode& getJITCode() { return ownerExecutable()->generatedJITCode(); }
     362        ExecutablePool* executablePool() { return ownerExecutable()->getExecutablePool(); }
     363#endif
     364
     365        ExecutableBase* ownerExecutable() const { return m_ownerExecutable; }
    354366
    355367        void setGlobalData(JSGlobalData* globalData) { m_globalData = globalData; }
     
    406418        bool hasExceptionInfo() const { return m_exceptionInfo; }
    407419        void clearExceptionInfo() { m_exceptionInfo.clear(); }
     420        ExceptionInfo* extractExceptionInfo() { ASSERT(m_exceptionInfo); return m_exceptionInfo.release(); }
    408421
    409422        void addExpressionInfo(const ExpressionRangeInfo& expressionInfo) { ASSERT(m_exceptionInfo); m_exceptionInfo->m_expressionInfo.append(expressionInfo); }
     
    430443        ALWAYS_INLINE JSValue getConstant(int index) const { return m_constantRegisters[index - FirstConstantRegisterIndex].jsValue(); }
    431444
    432         unsigned addFunction(PassRefPtr<FunctionBodyNode> n) { unsigned size = m_functions.size(); m_functions.append(n); return size; }
    433         FunctionBodyNode* function(int index) { return m_functions[index].get(); }
     445        unsigned addFunctionDecl(PassRefPtr<FunctionExecutable> n) { unsigned size = m_functionDecls.size(); m_functionDecls.append(n); return size; }
     446        FunctionExecutable* functionDecl(int index) { return m_functionDecls[index].get(); }
     447        int numberOfFunctionDecls() { return m_functionDecls.size(); }
     448        unsigned addFunctionExpr(PassRefPtr<FunctionExecutable> n) { unsigned size = m_functionExprs.size(); m_functionExprs.append(n); return size; }
     449        FunctionExecutable* functionExpr(int index) { return m_functionExprs[index].get(); }
    434450
    435451        unsigned addRegExp(RegExp* r) { createRareDataIfNecessary(); unsigned size = m_rareData->m_regexps.size(); m_rareData->m_regexps.append(r); return size; }
     
    478494        }
    479495
    480         ScopeNode* m_ownerNode;
     496        ExecutableBase* m_ownerExecutable;
    481497        JSGlobalData* m_globalData;
    482498
     
    514530        Vector<Identifier> m_identifiers;
    515531        Vector<Register> m_constantRegisters;
    516         Vector< RefPtr<FunctionBodyNode> > m_functions;
     532        Vector<RefPtr<FunctionExecutable> > m_functionDecls;
     533        Vector<RefPtr<FunctionExecutable> > m_functionExprs;
    517534
    518535        SymbolTable m_symbolTable;
    519536
    520         struct ExceptionInfo : FastAllocBase {
    521             Vector<ExpressionRangeInfo> m_expressionInfo;
    522             Vector<LineInfo> m_lineInfo;
    523             Vector<GetByIdExceptionInfo> m_getByIdExceptionInfo;
    524 
    525 #if ENABLE(JIT)
    526             Vector<CallReturnOffsetToBytecodeIndex> m_callReturnIndexVector;
    527 #endif
    528         };
    529537        OwnPtr<ExceptionInfo> m_exceptionInfo;
    530538
     
    554562    class GlobalCodeBlock : public CodeBlock {
    555563    public:
    556         GlobalCodeBlock(ScopeNode* ownerNode, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, JSGlobalObject* globalObject)
    557             : CodeBlock(ownerNode, codeType, sourceProvider, sourceOffset)
     564        GlobalCodeBlock(ExecutableBase* ownerExecutable, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, JSGlobalObject* globalObject)
     565            : CodeBlock(ownerExecutable, codeType, sourceProvider, sourceOffset)
    558566            , m_globalObject(globalObject)
    559567        {
     
    575583    class ProgramCodeBlock : public GlobalCodeBlock {
    576584    public:
    577         ProgramCodeBlock(ScopeNode* ownerNode, CodeType codeType, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider)
    578             : GlobalCodeBlock(ownerNode, codeType, sourceProvider, 0, globalObject)
     585        ProgramCodeBlock(ProgramExecutable* ownerExecutable, CodeType codeType, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider)
     586            : GlobalCodeBlock(ownerExecutable, codeType, sourceProvider, 0, globalObject)
    579587        {
    580588        }
     
    583591    class EvalCodeBlock : public GlobalCodeBlock {
    584592    public:
    585         EvalCodeBlock(ScopeNode* ownerNode, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider, int baseScopeDepth)
    586             : GlobalCodeBlock(ownerNode, EvalCode, sourceProvider, 0, globalObject)
     593        EvalCodeBlock(EvalExecutable* ownerExecutable, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider, int baseScopeDepth)
     594            : GlobalCodeBlock(ownerExecutable, EvalCode, sourceProvider, 0, globalObject)
    587595            , m_baseScopeDepth(baseScopeDepth)
    588596        {
     
    597605    class FunctionCodeBlock : public CodeBlock {
    598606    public:
    599         FunctionCodeBlock(ScopeNode* ownerNode, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)
    600             : CodeBlock(ownerNode, codeType, sourceProvider, sourceOffset)
     607        FunctionCodeBlock(FunctionExecutable* ownerExecutable, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)
     608            : CodeBlock(ownerExecutable, codeType, sourceProvider, sourceOffset)
    601609        {
    602610        }
     
    605613    class NativeCodeBlock : public CodeBlock {
    606614    public:
    607         NativeCodeBlock(ScopeNode* ownerNode)
    608             : CodeBlock(ownerNode)
     615        NativeCodeBlock(FunctionExecutable* ownerExecutable)
     616            : CodeBlock(ownerExecutable)
    609617        {
    610618        }
  • trunk/JavaScriptCore/bytecode/EvalCodeCache.h

    r47405 r47412  
    6565        bool isEmpty() const { return m_cacheMap.isEmpty(); }
    6666
    67         void markAggregate(MarkStack& markStack)
    68         {
    69             EvalCacheMap::iterator end = m_cacheMap.end();
    70             for (EvalCacheMap::iterator ptr = m_cacheMap.begin(); ptr != end; ++ptr)
    71                 ptr->second->markAggregate(markStack);
    72         }
    7367    private:
    7468        static const int maxCacheableSourceLength = 256;
  • trunk/JavaScriptCore/bytecode/SamplingTool.cpp

    r43663 r47412  
    198198    if (CodeBlock* codeBlock = sample.codeBlock()) {
    199199        MutexLocker locker(m_scopeSampleMapMutex);
    200         ScopeSampleRecord* record = m_scopeSampleMap->get(codeBlock->ownerNode());
     200        ScopeSampleRecord* record = m_scopeSampleMap->get(codeBlock->ownerExecutable());
    201201        ASSERT(record);
    202202        record->sample(codeBlock, sample.vPC());
  • trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r47236 r47412  
    274274        for (size_t i = 0; i < functionStack.size(); ++i) {
    275275            FunctionBodyNode* function = functionStack[i];
    276             globalObject->putWithAttributes(exec, function->ident(), function->make(exec, scopeChain.node()), DontDelete);
     276            globalObject->putWithAttributes(exec, function->ident(), new (exec) JSFunction(exec, adoptRef(new FunctionExecutable(function->ident(), function)), scopeChain.node()), DontDelete);
    277277        }
    278278        for (size_t i = 0; i < varStack.size(); ++i) {
     
    398398    m_codeBlock->m_numParameters = 1; // Allocate space for "this"
    399399
     400    const DeclarationStacks::FunctionStack& functionStack = evalNode->functionStack();
     401    for (size_t i = 0; i < functionStack.size(); ++i) {
     402        FunctionBodyNode* function = functionStack[i];
     403        m_codeBlock->addFunctionDecl(adoptRef(new FunctionExecutable(function->ident(), function)));
     404    }
     405
    400406    preserveLastVar();
    401407}
     
    765771    instructions().append(target->offsetFrom(instructions().size()));
    766772    return target;
    767 }
    768 
    769 unsigned BytecodeGenerator::addConstant(FunctionBodyNode* n)
    770 {
    771     // No need to explicitly unique function body nodes -- they're unique already.
    772     return m_codeBlock->addFunction(n);
    773773}
    774774
     
    13091309}
    13101310
    1311 RegisterID* BytecodeGenerator::emitNewFunction(RegisterID* dst, FunctionBodyNode* body)
    1312 {
     1311RegisterID* BytecodeGenerator::emitNewFunction(RegisterID* dst, FunctionBodyNode* function)
     1312{
     1313    unsigned index = m_codeBlock->addFunctionDecl(adoptRef(new FunctionExecutable(function->ident(), function)));
     1314
    13131315    emitOpcode(op_new_func);
    13141316    instructions().append(dst->index());
    1315     instructions().append(addConstant(body));
     1317    instructions().append(index);
    13161318    return dst;
    13171319}
     
    13281330RegisterID* BytecodeGenerator::emitNewFunctionExpression(RegisterID* r0, FuncExprNode* n)
    13291331{
     1332    FunctionBodyNode* function = n->body();
     1333    unsigned index = m_codeBlock->addFunctionExpr(adoptRef(new FunctionExecutable(function->ident(), function)));
     1334
    13301335    emitOpcode(op_new_func_exp);
    13311336    instructions().append(r0->index());
    1332     instructions().append(addConstant(n->body()));
     1337    instructions().append(index);
    13331338    return r0;
    13341339}
  • trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r47265 r47412  
    414414        }
    415415
    416         unsigned addConstant(FunctionBodyNode*);
    417416        unsigned addConstant(const Identifier&);
    418417        RegisterID* addConstantValue(JSValue);
  • trunk/JavaScriptCore/debugger/Debugger.cpp

    r47304 r47412  
    6262        return;
    6363
    64     Vector<ProtectedPtr<JSFunction> > functions;
     64    typedef HashSet<FunctionExecutable*> FunctionExecutableSet;
     65    typedef HashMap<SourceProvider*, ExecState*> SourceProviderMap;
     66
     67    FunctionExecutableSet functionExecutables;
     68    SourceProviderMap sourceProviders;
     69
    6570    Heap::iterator heapEnd = globalData->heap.primaryHeapEnd();
    6671    for (Heap::iterator it = globalData->heap.primaryHeapBegin(); it != heapEnd; ++it) {
    67         if ((*it)->inherits(&JSFunction::info)) {
    68             JSFunction* function = asFunction(*it);
    69             if (!function->body()->isHostFunction())
    70                 functions.append(function);
    71         }
     72        if (!(*it)->inherits(&JSFunction::info))
     73            continue;
     74
     75        JSFunction* function = asFunction(*it);
     76        if (function->executable()->isHostFunction())
     77            continue;
     78
     79        FunctionExecutable* executable = function->executable();
     80
     81        // Check if the function is already in the set - if so,
     82        // we've already retranslated it, nothing to do here.
     83        if (!functionExecutables.add(executable).second)
     84            continue;
     85
     86        ExecState* exec = function->scope().globalObject()->JSGlobalObject::globalExec();
     87        executable->recompile(exec);
     88        if (function->scope().globalObject()->debugger() == this)
     89            sourceProviders.add(executable->source().provider(), exec);
    7290    }
    7391
    74     typedef HashMap<RefPtr<FunctionBodyNode>, RefPtr<FunctionBodyNode> > FunctionBodyMap;
    75     typedef HashMap<SourceProvider*, ExecState*> SourceProviderMap;
    76 
    77     FunctionBodyMap functionBodies;
    78     SourceProviderMap sourceProviders;
    79 
    80     size_t size = functions.size();
    81     for (size_t i = 0; i < size; ++i) {
    82         JSFunction* function = functions[i];
    83 
    84         FunctionBodyNode* oldBody = function->body();
    85         pair<FunctionBodyMap::iterator, bool> result = functionBodies.add(oldBody, 0);
    86         if (!result.second) {
    87             function->setBody(result.first->second);
    88             continue;
    89         }
    90 
    91         ExecState* exec = function->scope().globalObject()->JSGlobalObject::globalExec();
    92         const SourceCode& sourceCode = oldBody->source();
    93 
    94         RefPtr<FunctionBodyNode> newBody = globalData->parser->parse<FunctionBodyNode>(exec, 0, sourceCode);
    95         ASSERT(newBody);
    96         newBody->finishParsing(oldBody->copyParameters(), oldBody->parameterCount(), oldBody->ident());
    97 
    98         result.first->second = newBody;
    99         function->setBody(newBody.release());
    100 
    101         if (function->scope().globalObject()->debugger() == this)
    102             sourceProviders.add(sourceCode.provider(), exec);
    103     }
    10492
    10593    // Call sourceParsed() after reparsing all functions because it will execute
  • trunk/JavaScriptCore/interpreter/CachedCall.h

    r45891 r47412  
    4141            , m_globalObjectScope(callFrame, callFrame->globalData().dynamicGlobalObject ? callFrame->globalData().dynamicGlobalObject : function->scope().node()->globalObject())
    4242        {
    43             m_closure = m_interpreter->prepareForRepeatCall(function->body(), callFrame, function, argCount, function->scope().node(), exception);
     43            m_closure = m_interpreter->prepareForRepeatCall(function->executable(), callFrame, function, argCount, function->scope().node(), exception);
    4444            m_valid = !*exception;
    4545        }
  • trunk/JavaScriptCore/interpreter/CallFrameClosure.h

    r46598 r47412  
    3333    CallFrame* newCallFrame;
    3434    JSFunction* function;
    35     FunctionBodyNode* functionBody;
     35    FunctionExecutable* functionExecutable;
    3636    JSGlobalData* globalData;
    3737    Register* oldEnd;
  • trunk/JavaScriptCore/interpreter/Interpreter.cpp

    r47405 r47412  
    490490        DebuggerCallFrame debuggerCallFrame(callFrame, exceptionValue);
    491491        if (callFrame->callee())
    492             debugger->returnEvent(debuggerCallFrame, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->lastLine());
     492            debugger->returnEvent(debuggerCallFrame, codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->lastLine());
    493493        else
    494             debugger->didExecuteProgram(debuggerCallFrame, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->lastLine());
     494            debugger->didExecuteProgram(debuggerCallFrame, codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->lastLine());
    495495    }
    496496
     
    499499            profiler->didExecute(callFrame, callFrame->callee());
    500500        else
    501             profiler->didExecute(callFrame, codeBlock->ownerNode()->sourceURL(), codeBlock->ownerNode()->lineNo());
     501            profiler->didExecute(callFrame, codeBlock->ownerExecutable()->sourceURL(), codeBlock->ownerExecutable()->lineNo());
    502502    }
    503503
     
    555555                } else
    556556                    exception->putWithAttributes(callFrame, Identifier(callFrame, "line"), jsNumber(callFrame, codeBlock->lineNumberForBytecodeOffset(callFrame, bytecodeOffset)), ReadOnly | DontDelete);
    557                 exception->putWithAttributes(callFrame, Identifier(callFrame, "sourceId"), jsNumber(callFrame, codeBlock->ownerNode()->sourceID()), ReadOnly | DontDelete);
    558                 exception->putWithAttributes(callFrame, Identifier(callFrame, "sourceURL"), jsOwnedString(callFrame, codeBlock->ownerNode()->sourceURL()), ReadOnly | DontDelete);
     557                exception->putWithAttributes(callFrame, Identifier(callFrame, "sourceId"), jsNumber(callFrame, codeBlock->ownerExecutable()->sourceID()), ReadOnly | DontDelete);
     558                exception->putWithAttributes(callFrame, Identifier(callFrame, "sourceURL"), jsOwnedString(callFrame, codeBlock->ownerExecutable()->sourceURL()), ReadOnly | DontDelete);
    559559            }
    560560           
     
    570570    if (Debugger* debugger = callFrame->dynamicGlobalObject()->debugger()) {
    571571        DebuggerCallFrame debuggerCallFrame(callFrame, exceptionValue);
    572         debugger->exception(debuggerCallFrame, codeBlock->ownerNode()->sourceID(), codeBlock->lineNumberForBytecodeOffset(callFrame, bytecodeOffset));
     572        debugger->exception(debuggerCallFrame, codeBlock->ownerExecutable()->sourceID(), codeBlock->lineNumberForBytecodeOffset(callFrame, bytecodeOffset));
    573573    }
    574574
     
    671671}
    672672
    673 JSValue Interpreter::execute(FunctionBodyNode* functionBodyNode, CallFrame* callFrame, JSFunction* function, JSObject* thisObj, const ArgList& args, ScopeChainNode* scopeChain, JSValue* exception)
     673JSValue Interpreter::execute(FunctionExecutable* functionExecutable, CallFrame* callFrame, JSFunction* function, JSObject* thisObj, const ArgList& args, ScopeChainNode* scopeChain, JSValue* exception)
    674674{
    675675    ASSERT(!scopeChain->globalData->exception);
     
    699699        newCallFrame->r(++dst) = *it;
    700700
    701     CodeBlock* codeBlock = &functionBodyNode->bytecode(scopeChain);
     701    CodeBlock* codeBlock = &functionExecutable->bytecode(scopeChain);
    702702    newCallFrame = slideRegisterWindowForCall(codeBlock, &m_registerFile, newCallFrame, argc + RegisterFile::CallFrameHeaderSize, argc);
    703703    if (UNLIKELY(!newCallFrame)) {
     
    719719        m_reentryDepth++;
    720720#if ENABLE(JIT)
    721         result = functionBodyNode->jitCode(scopeChain).execute(&m_registerFile, newCallFrame, scopeChain->globalData, exception);
     721        result = functionExecutable->jitCode(scopeChain).execute(&m_registerFile, newCallFrame, scopeChain->globalData, exception);
    722722#else
    723723        result = privateExecute(Normal, &m_registerFile, newCallFrame, exception);
     
    733733}
    734734
    735 CallFrameClosure Interpreter::prepareForRepeatCall(FunctionBodyNode* functionBodyNode, CallFrame* callFrame, JSFunction* function, int argCount, ScopeChainNode* scopeChain, JSValue* exception)
     735CallFrameClosure Interpreter::prepareForRepeatCall(FunctionExecutable* FunctionExecutable, CallFrame* callFrame, JSFunction* function, int argCount, ScopeChainNode* scopeChain, JSValue* exception)
    736736{
    737737    ASSERT(!scopeChain->globalData->exception);
     
    757757        newCallFrame->r(++dst) = jsUndefined();
    758758   
    759     CodeBlock* codeBlock = &functionBodyNode->bytecode(scopeChain);
     759    CodeBlock* codeBlock = &FunctionExecutable->bytecode(scopeChain);
    760760    newCallFrame = slideRegisterWindowForCall(codeBlock, &m_registerFile, newCallFrame, argc + RegisterFile::CallFrameHeaderSize, argc);
    761761    if (UNLIKELY(!newCallFrame)) {
     
    767767    newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), 0, argc, function);
    768768#if ENABLE(JIT)
    769     functionBodyNode->jitCode(scopeChain);
     769    FunctionExecutable->jitCode(scopeChain);
    770770#endif
    771771
    772     CallFrameClosure result = { callFrame, newCallFrame, function, functionBodyNode, scopeChain->globalData, oldEnd, scopeChain, codeBlock->m_numParameters, argc };
     772    CallFrameClosure result = { callFrame, newCallFrame, function, FunctionExecutable, scopeChain->globalData, oldEnd, scopeChain, codeBlock->m_numParameters, argc };
    773773    return result;
    774774}
     
    787787        m_reentryDepth++;
    788788#if ENABLE(JIT)
    789         result = closure.functionBody->generatedJITCode().execute(&m_registerFile, closure.newCallFrame, closure.globalData, exception);
     789        result = closure.functionExecutable->generatedJITCode().execute(&m_registerFile, closure.newCallFrame, closure.globalData, exception);
    790790#else
    791791        result = privateExecute(Normal, &m_registerFile, closure.newCallFrame, exception);
     
    837837        BatchedTransitionOptimizer optimizer(variableObject);
    838838
    839         const DeclarationStacks::VarStack& varStack = codeBlock->ownerNode()->varStack();
     839        const DeclarationStacks::VarStack& varStack = static_cast<EvalExecutable*>(codeBlock->ownerExecutable())->varStack();
    840840        DeclarationStacks::VarStack::const_iterator varStackEnd = varStack.end();
    841841        for (DeclarationStacks::VarStack::const_iterator it = varStack.begin(); it != varStackEnd; ++it) {
     
    847847        }
    848848
    849         const DeclarationStacks::FunctionStack& functionStack = codeBlock->ownerNode()->functionStack();
    850         DeclarationStacks::FunctionStack::const_iterator functionStackEnd = functionStack.end();
    851         for (DeclarationStacks::FunctionStack::const_iterator it = functionStack.begin(); it != functionStackEnd; ++it) {
     849        int numFunctions = codeBlock->numberOfFunctionDecls();
     850        for (int i = 0; i < numFunctions; ++i) {
     851            FunctionExecutable* function = codeBlock->functionDecl(i);
    852852            PutPropertySlot slot;
    853             variableObject->put(callFrame, (*it)->ident(), (*it)->make(callFrame, scopeChain), slot);
     853            variableObject->put(callFrame, function->name(), function->make(callFrame, scopeChain), slot);
    854854        }
    855855
     
    904904    switch (debugHookID) {
    905905        case DidEnterCallFrame:
    906             debugger->callEvent(callFrame, callFrame->codeBlock()->ownerNode()->sourceID(), firstLine);
     906            debugger->callEvent(callFrame, callFrame->codeBlock()->ownerExecutable()->sourceID(), firstLine);
    907907            return;
    908908        case WillLeaveCallFrame:
    909             debugger->returnEvent(callFrame, callFrame->codeBlock()->ownerNode()->sourceID(), lastLine);
     909            debugger->returnEvent(callFrame, callFrame->codeBlock()->ownerExecutable()->sourceID(), lastLine);
    910910            return;
    911911        case WillExecuteStatement:
    912             debugger->atStatement(callFrame, callFrame->codeBlock()->ownerNode()->sourceID(), firstLine);
     912            debugger->atStatement(callFrame, callFrame->codeBlock()->ownerExecutable()->sourceID(), firstLine);
    913913            return;
    914914        case WillExecuteProgram:
    915             debugger->willExecuteProgram(callFrame, callFrame->codeBlock()->ownerNode()->sourceID(), firstLine);
     915            debugger->willExecuteProgram(callFrame, callFrame->codeBlock()->ownerExecutable()->sourceID(), firstLine);
    916916            return;
    917917        case DidExecuteProgram:
    918             debugger->didExecuteProgram(callFrame, callFrame->codeBlock()->ownerNode()->sourceID(), lastLine);
     918            debugger->didExecuteProgram(callFrame, callFrame->codeBlock()->ownerExecutable()->sourceID(), lastLine);
    919919            return;
    920920        case DidReachBreakpoint:
    921             debugger->didReachBreakpoint(callFrame, callFrame->codeBlock()->ownerNode()->sourceID(), lastLine);
     921            debugger->didReachBreakpoint(callFrame, callFrame->codeBlock()->ownerExecutable()->sourceID(), lastLine);
    922922            return;
    923923    }
     
    29212921        int func = (++vPC)->u.operand;
    29222922
    2923         callFrame->r(dst) = JSValue(callFrame->codeBlock()->function(func)->make(callFrame, callFrame->scopeChain()));
     2923        callFrame->r(dst) = JSValue(callFrame->codeBlock()->functionDecl(func)->make(callFrame, callFrame->scopeChain()));
    29242924
    29252925        ++vPC;
     
    29372937        int funcIndex = (++vPC)->u.operand;
    29382938
    2939         FunctionBodyNode* body = callFrame->codeBlock()->function(funcIndex);
    2940         JSFunction* func = body->make(callFrame, callFrame->scopeChain());
     2939        FunctionExecutable* function = callFrame->codeBlock()->functionExpr(funcIndex);
     2940        JSFunction* func = function->make(callFrame, callFrame->scopeChain());
    29412941
    29422942        /*
     
    29472947            does not affect the scope enclosing the FunctionExpression.
    29482948         */
    2949         if (!body->ident().isNull()) {
    2950             JSStaticScopeObject* functionScopeObject = new (callFrame) JSStaticScopeObject(callFrame, body->ident(), func, ReadOnly | DontDelete);
     2949        if (!function->name().isNull()) {
     2950            JSStaticScopeObject* functionScopeObject = new (callFrame) JSStaticScopeObject(callFrame, function->name(), func, ReadOnly | DontDelete);
    29512951            func->scope().push(functionScopeObject);
    29522952        }
     
    30183018        if (callType == CallTypeJS) {
    30193019            ScopeChainNode* callDataScopeChain = callData.js.scopeChain;
    3020             FunctionBodyNode* functionBodyNode = callData.js.functionBody;
    3021             CodeBlock* newCodeBlock = &functionBodyNode->bytecode(callDataScopeChain);
     3020            CodeBlock* newCodeBlock = &callData.js.functionExecutable->bytecode(callDataScopeChain);
    30223021
    30233022            CallFrame* previousCallFrame = callFrame;
     
    30853084                goto vm_throw;
    30863085            }
    3087             int32_t expectedParams = callFrame->callee()->body()->parameterCount();
     3086            int32_t expectedParams = callFrame->callee()->executable()->parameterCount();
    30883087            int32_t inplaceArgs = min(argCount, expectedParams);
    30893088            int32_t i = 0;
     
    31723171        if (callType == CallTypeJS) {
    31733172            ScopeChainNode* callDataScopeChain = callData.js.scopeChain;
    3174             FunctionBodyNode* functionBodyNode = callData.js.functionBody;
    3175             CodeBlock* newCodeBlock = &functionBodyNode->bytecode(callDataScopeChain);
     3173            CodeBlock* newCodeBlock = &callData.js.functionExecutable->bytecode(callDataScopeChain);
    31763174           
    31773175            CallFrame* previousCallFrame = callFrame;
     
    33353333
    33363334        int dst = (++vPC)->u.operand;
    3337         JSActivation* activation = new (globalData) JSActivation(callFrame, static_cast<FunctionBodyNode*>(codeBlock->ownerNode()));
     3335        JSActivation* activation = new (globalData) JSActivation(callFrame, static_cast<FunctionExecutable*>(codeBlock->ownerExecutable()));
    33383336        callFrame->r(dst) = JSValue(activation);
    33393337        callFrame->setScopeChain(callFrame->scopeChain()->copy()->push(activation));
     
    34213419        if (constructType == ConstructTypeJS) {
    34223420            ScopeChainNode* callDataScopeChain = constructData.js.scopeChain;
    3423             FunctionBodyNode* functionBodyNode = constructData.js.functionBody;
    3424             CodeBlock* newCodeBlock = &functionBodyNode->bytecode(callDataScopeChain);
     3421            CodeBlock* newCodeBlock = &constructData.js.functionExecutable->bytecode(callDataScopeChain);
    34253422
    34263423            Structure* structure;
     
    36723669
    36733670        CodeBlock* codeBlock = callFrame->codeBlock();
    3674         callFrame->r(dst) = JSValue(Error::create(callFrame, (ErrorType)type, callFrame->r(message).jsValue().toString(callFrame), codeBlock->lineNumberForBytecodeOffset(callFrame, vPC - codeBlock->instructions().begin()), codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->sourceURL()));
     3671        callFrame->r(dst) = JSValue(Error::create(callFrame, (ErrorType)type, callFrame->r(message).jsValue().toString(callFrame), codeBlock->lineNumberForBytecodeOffset(callFrame, vPC - codeBlock->instructions().begin()), codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->sourceURL()));
    36753672
    36763673        ++vPC;
     
    39003897    unsigned bytecodeOffset = bytecodeOffsetForPC(callerFrame, callerCodeBlock, callFrame->returnPC());
    39013898    lineNumber = callerCodeBlock->lineNumberForBytecodeOffset(callerFrame, bytecodeOffset - 1);
    3902     sourceID = callerCodeBlock->ownerNode()->sourceID();
    3903     sourceURL = callerCodeBlock->ownerNode()->sourceURL();
     3899    sourceID = callerCodeBlock->ownerExecutable()->sourceID();
     3900    sourceURL = callerCodeBlock->ownerExecutable()->sourceURL();
    39043901    function = callerFrame->callee();
    39053902}
  • trunk/JavaScriptCore/interpreter/Interpreter.h

    r47304 r47412  
    4444    class CodeBlock;
    4545    class EvalExecutable;
    46     class FunctionBodyNode;
     46    class FunctionExecutable;
    4747    class InternalFunction;
    4848    class JSFunction;
     
    9797       
    9898        JSValue execute(ProgramExecutable*, CallFrame*, ScopeChainNode*, JSObject* thisObj, JSValue* exception);
    99         JSValue execute(FunctionBodyNode*, CallFrame*, JSFunction*, JSObject* thisObj, const ArgList& args, ScopeChainNode*, JSValue* exception);
     99        JSValue execute(FunctionExecutable*, CallFrame*, JSFunction*, JSObject* thisObj, const ArgList& args, ScopeChainNode*, JSValue* exception);
    100100        JSValue execute(EvalExecutable* evalNode, CallFrame* exec, JSObject* thisObj, ScopeChainNode* scopeChain, JSValue* exception);
    101101
     
    116116        enum ExecutionFlag { Normal, InitializeAndReturn };
    117117
    118         CallFrameClosure prepareForRepeatCall(FunctionBodyNode*, CallFrame*, JSFunction*, int argCount, ScopeChainNode*, JSValue* exception);
     118        CallFrameClosure prepareForRepeatCall(FunctionExecutable*, CallFrame*, JSFunction*, int argCount, ScopeChainNode*, JSValue* exception);
    119119        void endRepeatCall(CallFrameClosure&);
    120120        JSValue execute(CallFrameClosure&, JSValue* exception);
  • trunk/JavaScriptCore/jit/JIT.cpp

    r46879 r47412  
    439439}
    440440
    441 void JIT::privateCompile()
     441JITCode JIT::privateCompile()
    442442{
    443443    sampleCodeBlock(m_codeBlock);
     
    553553    }
    554554
    555     m_codeBlock->setJITCode(patchBuffer.finalizeCode());
     555    return patchBuffer.finalizeCode();
    556556}
    557557
  • trunk/JavaScriptCore/jit/JIT.h

    r47186 r47412  
    278278
    279279    public:
    280         static void compile(JSGlobalData* globalData, CodeBlock* codeBlock)
    281         {
    282             JIT jit(globalData, codeBlock);
    283             jit.privateCompile();
     280        static JITCode compile(JSGlobalData* globalData, CodeBlock* codeBlock)
     281        {
     282            return JIT(globalData, codeBlock).privateCompile();
    284283        }
    285284
     
    354353        void privateCompileLinkPass();
    355354        void privateCompileSlowCases();
    356         void privateCompile();
     355        JITCode privateCompile();
    357356        void privateCompileGetByIdProto(StructureStubInfo*, Structure*, Structure* prototypeStructure, size_t cachedOffset, ReturnAddressPtr returnAddress, CallFrame* callFrame);
    358357        void privateCompileGetByIdSelfList(StructureStubInfo*, PolymorphicAccessStructureList*, int, Structure*, size_t cachedOffset);
  • trunk/JavaScriptCore/jit/JITOpcodes.cpp

    r47089 r47412  
    6969
    7070    // regT0 holds callee, regT1 holds argCount.
    71     loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_body)), regT2);
    72     loadPtr(Address(regT2, OBJECT_OFFSETOF(FunctionBodyNode, m_code)), regT2);
     71    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_executable)), regT2);
     72    loadPtr(Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_codeBlock)), regT2);
    7373    Jump hasCodeBlock2 = branchTestPtr(NonZero, regT2);
    7474
     
    115115
    116116    // regT0 holds callee, regT1 holds argCount.
    117     loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_body)), regT2);
    118     loadPtr(Address(regT2, OBJECT_OFFSETOF(FunctionBodyNode, m_code)), regT2);
     117    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_executable)), regT2);
     118    loadPtr(Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_codeBlock)), regT2);
    119119    Jump hasCodeBlock3 = branchTestPtr(NonZero, regT2);
    120120
     
    147147    isNativeFunc3.link(this);
    148148    compileOpCallInitializeCallFrame();
    149     loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_body)), regT0);
    150     loadPtr(Address(regT0, OBJECT_OFFSETOF(FunctionBodyNode, m_jitCode)), regT0);
     149    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_executable)), regT0);
     150    loadPtr(Address(regT0, OBJECT_OFFSETOF(FunctionExecutable, m_jitCode)), regT0);
    151151    jump(regT0);
    152152
     
    545545{
    546546    JITStubCall stubCall(this, cti_op_new_func);
    547     stubCall.addArgument(ImmPtr(m_codeBlock->function(currentInstruction[2].u.operand)));
     547    stubCall.addArgument(ImmPtr(m_codeBlock->functionDecl(currentInstruction[2].u.operand)));
    548548    stubCall.call(currentInstruction[1].u.operand);
    549549}
     
    11811181{
    11821182    JITStubCall stubCall(this, cti_op_new_func_exp);
    1183     stubCall.addArgument(ImmPtr(m_codeBlock->function(currentInstruction[2].u.operand)));
     1183    stubCall.addArgument(ImmPtr(m_codeBlock->functionExpr(currentInstruction[2].u.operand)));
    11841184    stubCall.call(currentInstruction[1].u.operand);
    11851185}
     
    14881488
    14891489    // Load the callee CodeBlock* into eax
    1490     loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_body)), regT3);
    1491     loadPtr(Address(regT3, OBJECT_OFFSETOF(FunctionBodyNode, m_code)), regT0);
     1490    loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_executable)), regT3);
     1491    loadPtr(Address(regT3, OBJECT_OFFSETOF(FunctionExecutable, m_codeBlock)), regT0);
    14921492    Jump hasCodeBlock2 = branchTestPtr(NonZero, regT0);
    14931493    preserveReturnAddressAfterCall(regT3);
     
    15281528
    15291529    // Load the callee CodeBlock* into eax
    1530     loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_body)), regT3);
    1531     loadPtr(Address(regT3, OBJECT_OFFSETOF(FunctionBodyNode, m_code)), regT0);
     1530    loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_executable)), regT3);
     1531    loadPtr(Address(regT3, OBJECT_OFFSETOF(FunctionExecutable, m_codeBlock)), regT0);
    15321532    Jump hasCodeBlock3 = branchTestPtr(NonZero, regT0);
    15331533    preserveReturnAddressAfterCall(regT3);
     
    15371537    emitGetJITStubArg(3, regT1);
    15381538    restoreReturnAddressBeforeReturn(regT3);
    1539     loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_body)), regT3); // reload the function body nody, so we can reload the code pointer.
     1539    loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_executable)), regT3); // reload the function body nody, so we can reload the code pointer.
    15401540    hasCodeBlock3.link(this);
    15411541   
     
    15531553    emitGetJITStubArg(3, regT1);
    15541554    restoreReturnAddressBeforeReturn(regT3);
    1555     loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_body)), regT3); // reload the function body nody, so we can reload the code pointer.
     1555    loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_executable)), regT3); // reload the function body nody, so we can reload the code pointer.
    15561556    arityCheckOkay3.link(this);
    15571557    isNativeFunc3.link(this);
    15581558
    15591559    // load ctiCode from the new codeBlock.
    1560     loadPtr(Address(regT3, OBJECT_OFFSETOF(FunctionBodyNode, m_jitCode)), regT0);
     1560    loadPtr(Address(regT3, OBJECT_OFFSETOF(FunctionExecutable, m_jitCode)), regT0);
    15611561   
    15621562    compileOpCallInitializeCallFrame();
     
    19721972{
    19731973    JITStubCall stubCall(this, cti_op_new_func);
    1974     stubCall.addArgument(ImmPtr(m_codeBlock->function(currentInstruction[2].u.operand)));
     1974    stubCall.addArgument(ImmPtr(m_codeBlock->functionDecl(currentInstruction[2].u.operand)));
    19751975    stubCall.call(currentInstruction[1].u.operand);
    19761976}
     
    23262326{
    23272327    JITStubCall stubCall(this, cti_op_new_func_exp);
    2328     stubCall.addArgument(ImmPtr(m_codeBlock->function(currentInstruction[2].u.operand)));
     2328    stubCall.addArgument(ImmPtr(m_codeBlock->functionExpr(currentInstruction[2].u.operand)));
    23292329    stubCall.call(currentInstruction[1].u.operand);
    23302330}
  • trunk/JavaScriptCore/jit/JITStubs.cpp

    r47236 r47412  
    14811481
    14821482    JSFunction* function = asFunction(stackFrame.args[0].jsValue());
    1483     FunctionBodyNode* body = function->body();
    1484     ASSERT(!body->isHostFunction());
     1483    FunctionExecutable* executable = function->executable();
     1484    ASSERT(!executable->isHostFunction());
    14851485    ScopeChainNode* callDataScopeChain = function->scope().node();
    1486     body->jitCode(callDataScopeChain);
    1487 
    1488     return &body->generatedBytecode();
     1486    executable->jitCode(callDataScopeChain);
     1487
     1488    return &executable->generatedBytecode();
    14891489}
    14901490
     
    15401540    STUB_INIT_STACK_FRAME(stackFrame);
    15411541    JSFunction* callee = asFunction(stackFrame.args[0].jsValue());
    1542     FunctionBodyNode* body = callee->body();
    1543     JITCode& jitCode = body->generatedJITCode();
     1542    FunctionExecutable* executable = callee->executable();
     1543    JITCode& jitCode = executable->generatedJITCode();
    15441544   
    15451545    CodeBlock* codeBlock = 0;
    1546     if (!body->isHostFunction())
    1547         codeBlock = &body->bytecode(callee->scope().node());
     1546    if (!executable->isHostFunction())
     1547        codeBlock = &executable->bytecode(callee->scope().node());
    15481548    else
    1549         codeBlock = &body->generatedBytecode();
     1549        codeBlock = &executable->generatedBytecode();
    15501550    CallLinkInfo* callLinkInfo = &stackFrame.callFrame->callerFrame()->codeBlock()->getCallLinkInfo(stackFrame.args[1].returnAddress());
    15511551
     
    15631563    STUB_INIT_STACK_FRAME(stackFrame);
    15641564
    1565     JSActivation* activation = new (stackFrame.globalData) JSActivation(stackFrame.callFrame, static_cast<FunctionBodyNode*>(stackFrame.callFrame->codeBlock()->ownerNode()));
     1565    JSActivation* activation = new (stackFrame.globalData) JSActivation(stackFrame.callFrame, static_cast<FunctionExecutable*>(stackFrame.callFrame->codeBlock()->ownerExecutable()));
    15661566    stackFrame.callFrame->setScopeChain(stackFrame.callFrame->scopeChain()->copy()->push(activation));
    15671567    return activation;
     
    17171717
    17181718    JSFunction* constructor = asFunction(stackFrame.args[0].jsValue());
    1719     FunctionBodyNode* body = constructor->body();
    1720     if (body && body->isHostFunction()) {
     1719    FunctionExecutable* executable = constructor->executable();
     1720    if (executable && executable->isHostFunction()) {
    17211721        CallFrame* callFrame = stackFrame.callFrame;
    17221722        CodeBlock* codeBlock = callFrame->codeBlock();
     
    20452045            VM_THROW_EXCEPTION();
    20462046        }
    2047         int32_t expectedParams = callFrame->callee()->body()->parameterCount();
     2047        int32_t expectedParams = callFrame->callee()->executable()->parameterCount();
    20482048        int32_t inplaceArgs = min(providedParams, expectedParams);
    20492049       
     
    25222522    CallFrame* callFrame = stackFrame.callFrame;
    25232523
    2524     FunctionBodyNode* body = stackFrame.args[0].function();
    2525     JSFunction* func = body->make(callFrame, callFrame->scopeChain());
     2524    FunctionExecutable* function = stackFrame.args[0].function();
     2525    JSFunction* func = function->make(callFrame, callFrame->scopeChain());
    25262526
    25272527    /*
     
    25322532        does not affect the scope enclosing the FunctionExpression.
    25332533     */
    2534     if (!body->ident().isNull()) {
    2535         JSStaticScopeObject* functionScopeObject = new (callFrame) JSStaticScopeObject(callFrame, body->ident(), func, ReadOnly | DontDelete);
     2534    if (!function->name().isNull()) {
     2535        JSStaticScopeObject* functionScopeObject = new (callFrame) JSStaticScopeObject(callFrame, function->name(), func, ReadOnly | DontDelete);
    25362536        func->scope().push(functionScopeObject);
    25372537    }
     
    29972997
    29982998    unsigned lineNumber = codeBlock->lineNumberForBytecodeOffset(callFrame, bytecodeOffset);
    2999     return Error::create(callFrame, static_cast<ErrorType>(type), message.toString(callFrame), lineNumber, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->sourceURL());
     2999    return Error::create(callFrame, static_cast<ErrorType>(type), message.toString(callFrame), lineNumber, codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->sourceURL());
    30003000}
    30013001
  • trunk/JavaScriptCore/jit/JITStubs.h

    r47089 r47412  
    4343    class CodeBlock;
    4444    class ExecutablePool;
    45     class FunctionBodyNode;
     45    class FunctionExecutable;
    4646    class Identifier;
    4747    class JSGlobalData;
     
    6767        int32_t int32() { return asInt32; }
    6868        CodeBlock* codeBlock() { return static_cast<CodeBlock*>(asPointer); }
    69         FunctionBodyNode* function() { return static_cast<FunctionBodyNode*>(asPointer); }
     69        FunctionExecutable* function() { return static_cast<FunctionExecutable*>(asPointer); }
    7070        RegExp* regExp() { return static_cast<RegExp*>(asPointer); }
    7171        JSPropertyNameIterator* propertyNameIterator() { return static_cast<JSPropertyNameIterator*>(asPointer); }
  • trunk/JavaScriptCore/parser/Nodes.cpp

    r47304 r47412  
    18251825}
    18261826
    1827 void ScopeNodeData::markAggregate(MarkStack& markStack)
    1828 {
    1829     FunctionStack::iterator end = m_functionStack.end();
    1830     for (FunctionStack::iterator ptr = m_functionStack.begin(); ptr != end; ++ptr) {
    1831         FunctionBodyNode* body = *ptr;
    1832         if (!body->isGenerated())
    1833             continue;
    1834         body->generatedBytecode().markAggregate(markStack);
    1835     }
    1836 }
    1837 
    18381827// ------------------------------ ScopeNode -----------------------------
    18391828
     
    18931882}
    18941883
    1895 void ProgramNode::generateBytecode(ScopeChainNode* scopeChainNode)
    1896 {
    1897     ScopeChain scopeChain(scopeChainNode);
    1898     JSGlobalObject* globalObject = scopeChain.globalObject();
    1899    
    1900     m_code.set(new ProgramCodeBlock(this, GlobalCode, globalObject, source().provider()));
    1901    
    1902     OwnPtr<BytecodeGenerator> generator(new BytecodeGenerator(this, globalObject->debugger(), scopeChain, &globalObject->symbolTable(), m_code.get()));
    1903     generator->generate();
    1904 
    1905     destroyData();
    1906 }
    1907 
    1908 #if ENABLE(JIT)
    1909 void ProgramNode::generateJITCode(ScopeChainNode* scopeChainNode)
    1910 {
    1911     bytecode(scopeChainNode);
    1912     ASSERT(m_code);
    1913     ASSERT(!m_jitCode);
    1914     JIT::compile(scopeChainNode->globalData, m_code.get());
    1915     ASSERT(m_jitCode);
    1916 }
    1917 #endif
    1918 
    19191884// ------------------------------ EvalNode -----------------------------
    19201885
     
    19471912    return 0;
    19481913}
    1949 
    1950 void EvalNode::generateBytecode(ScopeChainNode* scopeChainNode)
    1951 {
    1952     ScopeChain scopeChain(scopeChainNode);
    1953     JSGlobalObject* globalObject = scopeChain.globalObject();
    1954 
    1955     m_code.set(new EvalCodeBlock(this, globalObject, source().provider(), scopeChain.localDepth()));
    1956 
    1957     OwnPtr<BytecodeGenerator> generator(new BytecodeGenerator(this, globalObject->debugger(), scopeChain, &m_code->symbolTable(), m_code.get()));
    1958     generator->generate();
    1959 
    1960     // Eval code needs to hang on to its declaration stacks to keep declaration info alive until Interpreter::execute time,
    1961     // so the entire ScopeNodeData cannot be destoyed.
    1962     children().clear();
    1963 }
    1964 
    1965 EvalCodeBlock& EvalNode::bytecodeForExceptionInfoReparse(ScopeChainNode* scopeChainNode, CodeBlock* codeBlockBeingRegeneratedFrom)
    1966 {
    1967     ASSERT(!m_code);
    1968 
    1969     ScopeChain scopeChain(scopeChainNode);
    1970     JSGlobalObject* globalObject = scopeChain.globalObject();
    1971 
    1972     m_code.set(new EvalCodeBlock(this, globalObject, source().provider(), scopeChain.localDepth()));
    1973 
    1974     OwnPtr<BytecodeGenerator> generator(new BytecodeGenerator(this, globalObject->debugger(), scopeChain, &m_code->symbolTable(), m_code.get()));
    1975     generator->setRegeneratingForExceptionInfo(codeBlockBeingRegeneratedFrom);
    1976     generator->generate();
    1977 
    1978     return *m_code;
    1979 }
    1980 
    1981 void EvalNode::markAggregate(MarkStack& markStack)
    1982 {
    1983     // We don't need to mark our own CodeBlock as the JSGlobalObject takes care of that
    1984     data()->markAggregate(markStack);
    1985 }
    1986 
    1987 #if ENABLE(JIT)
    1988 void EvalNode::generateJITCode(ScopeChainNode* scopeChainNode)
    1989 {
    1990     bytecode(scopeChainNode);
    1991     ASSERT(m_code);
    1992     ASSERT(!m_jitCode);
    1993     JIT::compile(scopeChainNode->globalData, m_code.get());
    1994     ASSERT(m_jitCode);
    1995 }
    1996 #endif
    19971914
    19981915// ------------------------------ FunctionBodyNode -----------------------------
     
    20381955}
    20391956
    2040 void FunctionBodyNode::markAggregate(MarkStack& markStack)
    2041 {
    2042     if (m_code)
    2043         m_code->markAggregate(markStack);
    2044 }
    2045 
    2046 #if ENABLE(JIT)
    2047 PassRefPtr<FunctionBodyNode> FunctionBodyNode::createNativeThunk(JSGlobalData* globalData)
    2048 {
    2049     RefPtr<FunctionBodyNode> body = new FunctionBodyNode(globalData);
    2050     globalData->parser->arena().reset();
    2051     body->m_code.set(new NativeCodeBlock(body.get()));
    2052     body->m_jitCode = JITCode(JITCode::HostFunction(globalData->jitStubs.ctiNativeCallThunk()));
    2053     return body.release();
    2054 }
    2055 #endif
    2056 
    2057 bool FunctionBodyNode::isHostFunction() const
    2058 {
    2059     return m_code && m_code->codeType() == NativeCode;
    2060 }
    2061 
    20621957FunctionBodyNode* FunctionBodyNode::create(JSGlobalData* globalData)
    20631958{
     
    20761971}
    20771972
    2078 void FunctionBodyNode::generateBytecode(ScopeChainNode* scopeChainNode)
     1973void FunctionBodyNode::reparseDataIfNecessary(ScopeChainNode* scopeChainNode)
    20791974{
    20801975    // This branch is only necessary since you can still create a non-stub FunctionBodyNode by
     
    20831978        scopeChainNode->globalData->parser->reparseInPlace(scopeChainNode->globalData, this);
    20841979    ASSERT(data());
    2085 
    2086     ScopeChain scopeChain(scopeChainNode);
    2087     JSGlobalObject* globalObject = scopeChain.globalObject();
    2088 
    2089     m_code.set(new FunctionCodeBlock(this, FunctionCode, source().provider(), source().startOffset()));
    2090 
    2091     OwnPtr<BytecodeGenerator> generator(new BytecodeGenerator(this, globalObject->debugger(), scopeChain, &m_code->symbolTable(), m_code.get()));
    2092     generator->generate();
    2093 
    2094     destroyData();
    2095 }
    2096 
    2097 #if ENABLE(JIT)
    2098 void FunctionBodyNode::generateJITCode(ScopeChainNode* scopeChainNode)
    2099 {
    2100     bytecode(scopeChainNode);
    2101     ASSERT(m_code);
    2102     ASSERT(!m_jitCode);
    2103     JIT::compile(scopeChainNode->globalData, m_code.get());
    2104     ASSERT(m_jitCode);
    2105 }
    2106 #endif
    2107 
    2108 CodeBlock& FunctionBodyNode::bytecodeForExceptionInfoReparse(ScopeChainNode* scopeChainNode, CodeBlock* codeBlockBeingRegeneratedFrom)
    2109 {
    2110     ASSERT(!m_code);
    2111 
    2112     ScopeChain scopeChain(scopeChainNode);
    2113     JSGlobalObject* globalObject = scopeChain.globalObject();
    2114 
    2115     m_code.set(new FunctionCodeBlock(this, FunctionCode, source().provider(), source().startOffset()));
    2116 
    2117     OwnPtr<BytecodeGenerator> generator(new BytecodeGenerator(this, globalObject->debugger(), scopeChain, &m_code->symbolTable(), m_code.get()));
    2118     generator->setRegeneratingForExceptionInfo(codeBlockBeingRegeneratedFrom);
    2119     generator->generate();
    2120 
    2121     return *m_code;
    21221980}
    21231981
     
    21572015}
    21582016
    2159 JSFunction* FunctionBodyNode::make(ExecState* exec, ScopeChainNode* scopeChain)
    2160 {
    2161     return new (exec) JSFunction(exec, m_ident, this, scopeChain);
    2162 }
    2163 
    21642017// ------------------------------ FuncDeclNode ---------------------------------
    21652018
  • trunk/JavaScriptCore/parser/Nodes.h

    r47259 r47412  
    4040
    4141    class ArgumentListNode;
     42    class BytecodeGenerator;
    4243    class CodeBlock;
    43     class BytecodeGenerator;
     44    class EvalCodeBlock;
     45    class EvalExecutable;
    4446    class FuncDeclNode;
    45     class EvalCodeBlock;
     47    class FunctionBodyNode;
     48    class FunctionCodeBlock;
    4649    class JSFunction;
    4750    class ProgramCodeBlock;
     51    class ProgramExecutable;
    4852    class PropertyListNode;
    4953    class ReadModifyResolveNode;
     
    13911395        int m_numConstants;
    13921396        StatementVector m_children;
    1393 
    1394         void markAggregate(MarkStack&);
    13951397    };
    13961398
     
    14381440        }
    14391441
    1440         virtual void markAggregate(MarkStack&) { }
    1441 
    1442 #if ENABLE(JIT)
    1443         JITCode& generatedJITCode()
    1444         {
    1445             ASSERT(m_jitCode);
    1446             return m_jitCode;
    1447         }
    1448 
    1449         ExecutablePool* getExecutablePool()
    1450         {
    1451             return m_jitCode.getExecutablePool();
    1452         }
    1453 
    1454         void setJITCode(const JITCode jitCode)
    1455         {
    1456             m_jitCode = jitCode;
    1457         }
    1458 #endif
    1459 
    14601442    protected:
    14611443        void setSource(const SourceCode& source) { m_source = source; }
    1462 
    1463 #if ENABLE(JIT)
    1464         JITCode m_jitCode;
    1465 #endif
    14661444
    14671445    private:
     
    14751453        static PassRefPtr<ProgramNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants);
    14761454
    1477         ProgramCodeBlock& bytecode(ScopeChainNode* scopeChain)
     1455    private:
     1456        ProgramNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants);
     1457
     1458        virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
     1459    };
     1460
     1461    class EvalNode : public ScopeNode {
     1462    public:
     1463        static PassRefPtr<EvalNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants);
     1464
     1465        void partialDestroyData()
    14781466        {
    1479             if (!m_code)
    1480                 generateBytecode(scopeChain);
    1481             return *m_code;
     1467            // Eval code needs to hang on to its declaration stacks to keep declaration info alive until Interpreter::execute time,
     1468            // so the entire ScopeNodeData cannot be destoyed.
     1469            children().clear();
    14821470        }
    14831471
    1484 #if ENABLE(JIT)
    1485         JITCode& jitCode(ScopeChainNode* scopeChain)
    1486         {
    1487             if (!m_jitCode)
    1488                 generateJITCode(scopeChain);
    1489             return m_jitCode;
    1490         }
    1491 #endif
    1492 
    1493     private:
    1494         ProgramNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants);
    1495 
    1496         void generateBytecode(ScopeChainNode*);
    1497         virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
    1498 
    1499 #if ENABLE(JIT)
    1500         void generateJITCode(ScopeChainNode*);
    1501 #endif
    1502 
    1503         OwnPtr<ProgramCodeBlock> m_code;
    1504     };
    1505 
    1506     class EvalNode : public ScopeNode {
    1507     public:
    1508         static PassRefPtr<EvalNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants);
    1509 
    1510         EvalCodeBlock& bytecode(ScopeChainNode* scopeChain)
    1511         {
    1512             if (!m_code)
    1513                 generateBytecode(scopeChain);
    1514             return *m_code;
    1515         }
    1516 
    1517         EvalCodeBlock& bytecodeForExceptionInfoReparse(ScopeChainNode*, CodeBlock*);
    1518 
    1519         virtual void markAggregate(MarkStack&);
    1520 
    1521 #if ENABLE(JIT)
    1522         JITCode& jitCode(ScopeChainNode* scopeChain)
    1523         {
    1524             if (!m_jitCode)
    1525                 generateJITCode(scopeChain);
    1526             return m_jitCode;
    1527         }
    1528 #endif
    1529 
    15301472    private:
    15311473        EvalNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants);
    15321474
    1533         void generateBytecode(ScopeChainNode*);
    1534         virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
    1535 
    1536 #if ENABLE(JIT)
    1537         void generateJITCode(ScopeChainNode*);
    1538 #endif
    1539        
    1540         OwnPtr<EvalCodeBlock> m_code;
     1475        virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
    15411476    };
    15421477
     
    15441479        friend class JIT;
    15451480    public:
    1546 #if ENABLE(JIT)
    1547         static PassRefPtr<FunctionBodyNode> createNativeThunk(JSGlobalData*);
    1548 #endif
    15491481        static FunctionBodyNode* create(JSGlobalData*);
    15501482        static PassRefPtr<FunctionBodyNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants);
     
    15581490        virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
    15591491
    1560         bool isGenerated() const
    1561         {
    1562             return m_code;
    1563         }
    1564 
    1565         bool isHostFunction() const;
    1566 
    1567         virtual void markAggregate(MarkStack&);
    1568 
    15691492        void finishParsing(const SourceCode&, ParameterNode*, const Identifier& ident);
    15701493        void finishParsing(Identifier* parameters, size_t parameterCount, const Identifier& ident);
    15711494       
    1572         UString toSourceString() const { return source().toString(); }
    1573 
    1574         CodeBlock& bytecodeForExceptionInfoReparse(ScopeChainNode*, CodeBlock*);
    1575 #if ENABLE(JIT)
    1576         JITCode& jitCode(ScopeChainNode* scopeChain)
    1577         {
    1578             if (!m_jitCode)
    1579                 generateJITCode(scopeChain);
    1580             return m_jitCode;
    1581         }
    1582 #endif
    1583 
    1584         CodeBlock& bytecode(ScopeChainNode* scopeChain)
    1585         {
    1586             ASSERT(scopeChain);
    1587             if (!m_code)
    1588                 generateBytecode(scopeChain);
    1589             return *m_code;
    1590         }
    1591        
    1592         CodeBlock& generatedBytecode()
    1593         {
    1594             ASSERT(m_code);
    1595             return *m_code;
    1596         }
    1597 
    15981495        const Identifier& ident() { return m_ident; }
    15991496
    1600         JSFunction* make(ExecState*, ScopeChainNode*);
     1497        void reparseDataIfNecessary(ScopeChainNode* scopeChainNode);
    16011498
    16021499    private:
    16031500        FunctionBodyNode(JSGlobalData*);
    16041501        FunctionBodyNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants);
    1605 
    1606         void generateBytecode(ScopeChainNode*);
    1607 #if ENABLE(JIT)
    1608         void generateJITCode(ScopeChainNode*);
    1609 #endif
    16101502        Identifier m_ident;
    16111503        Identifier* m_parameters;
    16121504        size_t m_parameterCount;
    1613         OwnPtr<CodeBlock> m_code;
    16141505    };
    16151506
  • trunk/JavaScriptCore/profiler/ProfileGenerator.cpp

    r43122 r47412  
    2828
    2929#include "CallFrame.h"
     30#include "CodeBlock.h"
    3031#include "JSGlobalObject.h"
    3132#include "JSStringRef.h"
  • trunk/JavaScriptCore/profiler/Profiler.cpp

    r47236 r47412  
    3232#include "CommonIdentifiers.h"
    3333#include "CallFrame.h"
     34#include "CodeBlock.h"
    3435#include "JSFunction.h"
    3536#include "JSGlobalObject.h"
     
    143144    if (asObject(functionValue)->inherits(&JSFunction::info)) {
    144145        JSFunction* function = asFunction(functionValue);
    145         if (!function->body()->isHostFunction())
     146        if (!function->executable()->isHostFunction())
    146147            return createCallIdentifierFromFunctionImp(globalData, function);
    147148    }
     
    154155{
    155156    const UString& name = function->calculatedDisplayName(globalData);
    156     return CallIdentifier(name.isEmpty() ? AnonymousFunction : name, function->body()->sourceURL(), function->body()->lineNo());
     157    return CallIdentifier(name.isEmpty() ? AnonymousFunction : name, function->executable()->sourceURL(), function->executable()->lineNo());
    157158}
    158159
  • trunk/JavaScriptCore/runtime/Arguments.h

    r47404 r47412  
    117117        function = callFrame->callee();
    118118   
    119         CodeBlock* codeBlock = &function->body()->generatedBytecode();
     119        CodeBlock* codeBlock = &function->executable()->generatedBytecode();
    120120        int numParameters = codeBlock->m_numParameters;
    121121        argc = callFrame->argumentCount();
     
    140140        getArgumentsData(callFrame, callee, firstParameterIndex, argv, numArguments);
    141141
    142         d->numParameters = callee->body()->parameterCount();
     142        d->numParameters = callee->executable()->parameterCount();
    143143        d->firstParameterIndex = firstParameterIndex;
    144144        d->numArguments = numArguments;
     
    171171        , d(new ArgumentsData)
    172172    {
    173         ASSERT(!callFrame->callee()->body()->parameterCount());
     173        ASSERT(!callFrame->callee()->executable()->parameterCount());
    174174
    175175        unsigned numArguments = callFrame->argumentCount() - 1;
     
    217217        ASSERT(!d()->registerArray);
    218218
    219         size_t numParametersMinusThis = d()->functionBody->generatedBytecode().m_numParameters - 1;
    220         size_t numVars = d()->functionBody->generatedBytecode().m_numVars;
     219        size_t numParametersMinusThis = d()->functionExecutable->generatedBytecode().m_numParameters - 1;
     220        size_t numVars = d()->functionExecutable->generatedBytecode().m_numVars;
    221221        size_t numLocals = numVars + numParametersMinusThis;
    222222
  • trunk/JavaScriptCore/runtime/ArrayPrototype.cpp

    r47288 r47412  
    7676    // If the JIT is enabled then we need to preserve the invariant that every
    7777    // function with a CodeBlock also has JIT code.
    78     callData.js.functionBody->jitCode(callData.js.scopeChain);
    79     CodeBlock& codeBlock = callData.js.functionBody->generatedBytecode();
     78    callData.js.functionExecutable->jitCode(callData.js.scopeChain);
     79    CodeBlock& codeBlock = callData.js.functionExecutable->generatedBytecode();
    8080#else
    81     CodeBlock& codeBlock = callData.js.functionBody->bytecode(callData.js.scopeChain);
     81    CodeBlock& codeBlock = callData.js.functionExecutable->bytecode(callData.js.scopeChain);
    8282#endif
    8383
  • trunk/JavaScriptCore/runtime/CallData.h

    r43372 r47412  
    3636    class ArgList;
    3737    class ExecState;
    38     class FunctionBodyNode;
     38    class FunctionExecutable;
    3939    class JSObject;
    4040    class JSValue;
     
    5454        } native;
    5555        struct {
    56             FunctionBodyNode* functionBody;
     56            FunctionExecutable* functionExecutable;
    5757            ScopeChainNode* scopeChain;
    5858        } js;
  • trunk/JavaScriptCore/runtime/Collector.cpp

    r47284 r47412  
    11391139    m_globalData->interpreter->registerFile().markCallFrames(markStack, this);
    11401140    m_globalData->smallStrings.mark();
    1141     if (m_globalData->scopeNodeBeingReparsed)
    1142         m_globalData->scopeNodeBeingReparsed->markAggregate(markStack);
     1141    if (m_globalData->functionCodeBlockBeingReparsed)
     1142        m_globalData->functionCodeBlockBeingReparsed->markAggregate(markStack);
    11431143    if (m_globalData->firstStringifierToMark)
    11441144        JSONObject::markStringifiers(markStack, m_globalData->firstStringifierToMark);
  • trunk/JavaScriptCore/runtime/ConstructData.h

    r43122 r47412  
    3434    class ArgList;
    3535    class ExecState;
    36     class FunctionBodyNode;
     36    class FunctionExecutable;
    3737    class JSObject;
    3838    class JSValue;
     
    5252        } native;
    5353        struct {
    54             FunctionBodyNode* functionBody;
     54            FunctionExecutable* functionExecutable;
    5555            ScopeChainNode* scopeChain;
    5656        } js;
  • trunk/JavaScriptCore/runtime/ExceptionHelpers.cpp

    r43122 r47412  
    7575    UString message = "Can't find variable: ";
    7676    message.append(ident.ustring());
    77     JSObject* exception = Error::create(exec, ReferenceError, message, line, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->sourceURL());
     77    JSObject* exception = Error::create(exec, ReferenceError, message, line, codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->sourceURL());
    7878    exception->putWithAttributes(exec, Identifier(exec, expressionBeginOffsetPropertyName), jsNumber(exec, divotPoint - startOffset), ReadOnly | DontDelete);
    7979    exception->putWithAttributes(exec, Identifier(exec, expressionCaretOffsetPropertyName), jsNumber(exec, divotPoint), ReadOnly | DontDelete);
     
    137137    int line = codeBlock->expressionRangeForBytecodeOffset(exec, bytecodeOffset, divotPoint, startOffset, endOffset);
    138138    UString errorMessage = createErrorMessage(exec, codeBlock, line, divotPoint, divotPoint + endOffset, value, message);
    139     JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->sourceURL());
     139    JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->sourceURL());
    140140    exception->putWithAttributes(exec, Identifier(exec, expressionBeginOffsetPropertyName), jsNumber(exec, divotPoint - startOffset), ReadOnly | DontDelete);
    141141    exception->putWithAttributes(exec, Identifier(exec, expressionCaretOffsetPropertyName), jsNumber(exec, divotPoint), ReadOnly | DontDelete);
     
    158158   
    159159    UString errorMessage = createErrorMessage(exec, codeBlock, line, startPoint, divotPoint, value, "not a constructor");
    160     JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->sourceURL());
     160    JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->sourceURL());
    161161    exception->putWithAttributes(exec, Identifier(exec, expressionBeginOffsetPropertyName), jsNumber(exec, divotPoint - startOffset), ReadOnly | DontDelete);
    162162    exception->putWithAttributes(exec, Identifier(exec, expressionCaretOffsetPropertyName), jsNumber(exec, divotPoint), ReadOnly | DontDelete);
     
    172172    int line = codeBlock->expressionRangeForBytecodeOffset(exec, bytecodeOffset, divotPoint, startOffset, endOffset);
    173173    UString errorMessage = createErrorMessage(exec, codeBlock, line, divotPoint - startOffset, divotPoint, value, "not a function");
    174     JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->sourceURL());   
     174    JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->sourceURL());   
    175175    exception->putWithAttributes(exec, Identifier(exec, expressionBeginOffsetPropertyName), jsNumber(exec, divotPoint - startOffset), ReadOnly | DontDelete);
    176176    exception->putWithAttributes(exec, Identifier(exec, expressionCaretOffsetPropertyName), jsNumber(exec, divotPoint), ReadOnly | DontDelete);
     
    202202    int line = codeBlock->expressionRangeForBytecodeOffset(exec, bytecodeOffset, divotPoint, startOffset, endOffset);
    203203    UString errorMessage = createErrorMessage(exec, codeBlock, line, divotPoint - startOffset, divotPoint, error->isNull() ? jsNull() : jsUndefined(), "not an object");
    204     JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->sourceURL());
     204    JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->sourceURL());
    205205    exception->putWithAttributes(exec, Identifier(exec, expressionBeginOffsetPropertyName), jsNumber(exec, divotPoint - startOffset), ReadOnly | DontDelete);
    206206    exception->putWithAttributes(exec, Identifier(exec, expressionCaretOffsetPropertyName), jsNumber(exec, divotPoint), ReadOnly | DontDelete);
  • trunk/JavaScriptCore/runtime/Executable.h

    r47405 r47412  
    3131namespace JSC {
    3232
    33     template<class ASTNodeType, class CodeBlockType>
    34     class TemplateExecutable {
    35     public:
    36         TemplateExecutable(const SourceCode& source)
     33    class CodeBlock;
     34    class EvalCodeBlock;
     35    class ProgramCodeBlock;
     36    class ScopeChainNode;
     37
     38    struct ExceptionInfo;
     39
     40    class ExecutableBase {
     41        friend class JIT;
     42    public:
     43        virtual ~ExecutableBase() {}
     44
     45        ExecutableBase(const SourceCode& source)
    3746            : m_source(source)
    3847        {
    3948        }
    4049
    41         void markAggregate(MarkStack& markStack)
    42         {
    43             m_node->markAggregate(markStack);
    44         }
    45 
     50        const SourceCode& source() { return m_source; }
     51        intptr_t sourceID() const { return m_node->sourceID(); }
    4652        const UString& sourceURL() const { return m_node->sourceURL(); }
    4753        int lineNo() const { return m_node->lineNo(); }
    48         CodeBlockType& bytecode(ScopeChainNode* scopeChainNode) { return m_node->bytecode(scopeChainNode); }
    49 
    50 #if ENABLE(JIT)
    51         JITCode& jitCode(ScopeChainNode* scopeChainNode) { return m_node->jitCode(scopeChainNode); }
    52 #endif
     54        int lastLine() const { return m_node->lastLine(); }
     55
     56        bool usesEval() const { return m_node->usesEval(); }
     57        bool usesArguments() const { return m_node->usesArguments(); }
     58        bool needsActivation() const { return m_node->needsActivation(); }
     59
     60        virtual ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*) = 0;
     61
     62        ScopeNode* astNode() { return m_node.get(); }
    5363
    5464    protected:
    55         RefPtr<ASTNodeType> m_node;
     65        RefPtr<ScopeNode> m_node;
    5666        SourceCode m_source;
    57     };
    58 
    59     class EvalExecutable : public TemplateExecutable<EvalNode, EvalCodeBlock> {
     67
     68    private:
     69        // For use making native thunk.
     70        friend class FunctionExecutable;
     71        ExecutableBase()
     72        {
     73        }
     74
     75#if ENABLE(JIT)
     76    public:
     77        JITCode& generatedJITCode()
     78        {
     79            ASSERT(m_jitCode);
     80            return m_jitCode;
     81        }
     82
     83        ExecutablePool* getExecutablePool()
     84        {
     85            return m_jitCode.getExecutablePool();
     86        }
     87
     88    protected:
     89        JITCode m_jitCode;
     90#endif
     91    };
     92
     93    class EvalExecutable : public ExecutableBase {
    6094    public:
    6195        EvalExecutable(const SourceCode& source)
    62             : TemplateExecutable<EvalNode, EvalCodeBlock>(source)
    63         {
    64         }
     96            : ExecutableBase(source)
     97            , m_evalCodeBlock(0)
     98        {
     99        }
     100
     101        ~EvalExecutable();
    65102
    66103        JSObject* parse(ExecState* exec, bool allowDebug = true);
     104
     105        EvalCodeBlock& bytecode(ScopeChainNode* scopeChainNode)
     106        {
     107            if (!m_evalCodeBlock)
     108                generateBytecode(scopeChainNode);
     109            return *m_evalCodeBlock;
     110        }
     111
     112        DeclarationStacks::VarStack& varStack() { return m_node->varStack(); }
     113
     114        ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*);
     115
     116    private:
     117        EvalNode* evalNode() { return static_cast<EvalNode*>(m_node.get()); }
     118
     119        void generateBytecode(ScopeChainNode*);
     120
     121        EvalCodeBlock* m_evalCodeBlock;
     122
     123#if ENABLE(JIT)
     124    public:
     125        JITCode& jitCode(ScopeChainNode* scopeChainNode)
     126        {
     127            if (!m_jitCode)
     128                generateJITCode(scopeChainNode);
     129            return m_jitCode;
     130        }
     131
     132    private:
     133        void generateJITCode(ScopeChainNode*);
     134#endif
    67135    };
    68136
     
    78146    };
    79147
    80     class ProgramExecutable : public TemplateExecutable<ProgramNode, ProgramCodeBlock> {
     148    class ProgramExecutable : public ExecutableBase {
    81149    public:
    82150        ProgramExecutable(const SourceCode& source)
    83             : TemplateExecutable<ProgramNode, ProgramCodeBlock>(source)
    84         {
    85         }
     151            : ExecutableBase(source)
     152            , m_programCodeBlock(0)
     153        {
     154        }
     155       
     156        ~ProgramExecutable();
    86157
    87158        JSObject* parse(ExecState* exec, bool allowDebug = true);
     159
     160        // CodeBlocks for program code are transient and therefore to not gain from from throwing out there exception information.
     161        ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*) { ASSERT_NOT_REACHED(); return 0; }
     162
     163        ProgramCodeBlock& bytecode(ScopeChainNode* scopeChainNode)
     164        {
     165            if (!m_programCodeBlock)
     166                generateBytecode(scopeChainNode);
     167            return *m_programCodeBlock;
     168        }
     169
     170    private:
     171        ProgramNode* programNode() { return static_cast<ProgramNode*>(m_node.get()); }
     172
     173        void generateBytecode(ScopeChainNode*);
     174
     175        ProgramCodeBlock* m_programCodeBlock;
     176
     177#if ENABLE(JIT)
     178    public:
     179        JITCode& jitCode(ScopeChainNode* scopeChainNode)
     180        {
     181            if (!m_jitCode)
     182                generateJITCode(scopeChainNode);
     183            return m_jitCode;
     184        }
     185
     186    private:
     187        void generateJITCode(ScopeChainNode*);
     188#endif
     189    };
     190
     191    class FunctionExecutable : public ExecutableBase, public RefCounted<FunctionExecutable> {
     192        friend class JIT;
     193    public:
     194        FunctionExecutable(const Identifier& name, FunctionBodyNode* body)
     195            : ExecutableBase(body->source())
     196            , m_codeBlock(0)
     197            , m_name(name)
     198        {
     199            m_node = body;
     200        }
     201
     202        ~FunctionExecutable();
     203
     204        const Identifier& name() { return m_name; }
     205
     206        JSFunction* make(ExecState* exec, ScopeChainNode* scopeChain);
     207
     208        CodeBlock& bytecode(ScopeChainNode* scopeChainNode)
     209        {
     210            ASSERT(scopeChainNode);
     211            if (!m_codeBlock)
     212                generateBytecode(scopeChainNode);
     213            return *m_codeBlock;
     214        }
     215        CodeBlock& generatedBytecode()
     216        {
     217            ASSERT(m_codeBlock);
     218            return *m_codeBlock;
     219        }
     220
     221        bool usesEval() const { return body()->usesEval(); }
     222        bool usesArguments() const { return body()->usesArguments(); }
     223        size_t parameterCount() const { return body()->parameterCount(); }
     224        UString paramString() const { return body()->paramString(); }
     225
     226        bool isHostFunction() const;
     227        bool isGenerated() const
     228        {
     229            return m_codeBlock;
     230        }
     231
     232        void recompile(ExecState* exec);
     233
     234        ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*);
     235
     236        void markAggregate(MarkStack& markStack);
     237
     238    private:
     239        FunctionBodyNode* body() const { return static_cast<FunctionBodyNode*>(m_node.get()); }
     240
     241        void generateBytecode(ScopeChainNode*);
     242
     243        CodeBlock* m_codeBlock;
     244        const Identifier& m_name;
     245
     246#if ENABLE(JIT)
     247    public:
     248        JITCode& jitCode(ScopeChainNode* scopeChainNode)
     249        {
     250            if (!m_jitCode)
     251                generateJITCode(scopeChainNode);
     252            return m_jitCode;
     253        }
     254
     255        static PassRefPtr<FunctionExecutable> createNativeThunk(ExecState* exec)
     256        {
     257            return adoptRef(new FunctionExecutable(exec));
     258        }
     259
     260    private:
     261        FunctionExecutable(ExecState* exec);
     262        void generateJITCode(ScopeChainNode*);
     263#endif
    88264    };
    89265
  • trunk/JavaScriptCore/runtime/FunctionConstructor.cpp

    r47304 r47412  
    9494    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
    9595    ScopeChain scopeChain(globalObject, globalObject->globalData(), exec->globalThisValue());
    96     return new (exec) JSFunction(exec, functionName, body.get(), scopeChain.node());
     96    return new (exec) JSFunction(exec, adoptRef(new FunctionExecutable(functionName, body.get())), scopeChain.node());
    9797}
    9898
  • trunk/JavaScriptCore/runtime/FunctionPrototype.cpp

    r47288 r47412  
    8787    if (thisValue.inherits(&JSFunction::info)) {
    8888        JSFunction* function = asFunction(thisValue);
    89         FunctionBodyNode* body = function->body();
    90         if (!body->isHostFunction()) {
    91             UString bodySourceString = body->toSourceString();
    92             insertSemicolonIfNeeded(bodySourceString);
    93             return jsString(exec, "function " + function->name(&exec->globalData()) + "(" + body->paramString() + ") " + bodySourceString);
     89        FunctionExecutable* executable = function->executable();
     90        if (!executable->isHostFunction()) {
     91            UString sourceString = executable->source().toString();
     92            insertSemicolonIfNeeded(sourceString);
     93            return jsString(exec, "function " + function->name(&exec->globalData()) + "(" + executable->paramString() + ") " + sourceString);
    9494        }
    9595    }
  • trunk/JavaScriptCore/runtime/JSActivation.cpp

    r47288 r47412  
    4040const ClassInfo JSActivation::info = { "JSActivation", 0, 0, 0 };
    4141
    42 JSActivation::JSActivation(CallFrame* callFrame, PassRefPtr<FunctionBodyNode> functionBody)
    43     : Base(callFrame->globalData().activationStructure, new JSActivationData(functionBody, callFrame->registers()))
     42JSActivation::JSActivation(CallFrame* callFrame, PassRefPtr<FunctionExecutable> functionExecutable)
     43    : Base(callFrame->globalData().activationStructure, new JSActivationData(functionExecutable, callFrame->registers()))
    4444{
    4545}
     
    5858        return;
    5959
    60     size_t numParametersMinusThis = d()->functionBody->generatedBytecode().m_numParameters - 1;
     60    size_t numParametersMinusThis = d()->functionExecutable->generatedBytecode().m_numParameters - 1;
    6161
    6262    size_t count = numParametersMinusThis;
    6363    markStack.appendValues(registerArray, count);
    6464
    65     size_t numVars = d()->functionBody->generatedBytecode().m_numVars;
     65    size_t numVars = d()->functionExecutable->generatedBytecode().m_numVars;
    6666
    6767    // Skip the call frame, which sits between the parameters and vars.
     
    137137bool JSActivation::isDynamicScope() const
    138138{
    139     return d()->functionBody->usesEval();
     139    return d()->functionExecutable->usesEval();
    140140}
    141141
     
    144144    JSActivation* activation = asActivation(slot.slotBase());
    145145
    146     if (activation->d()->functionBody->usesArguments()) {
     146    if (activation->d()->functionExecutable->usesArguments()) {
    147147        PropertySlot slot;
    148148        activation->symbolTableGet(exec->propertyNames().arguments, slot);
  • trunk/JavaScriptCore/runtime/JSActivation.h

    r47022 r47412  
    4444        typedef JSVariableObject Base;
    4545    public:
    46         JSActivation(CallFrame*, PassRefPtr<FunctionBodyNode>);
     46        JSActivation(CallFrame*, PassRefPtr<FunctionExecutable>);
    4747        virtual ~JSActivation();
    4848
     
    7171    private:
    7272        struct JSActivationData : public JSVariableObjectData {
    73             JSActivationData(PassRefPtr<FunctionBodyNode> functionBody, Register* registers)
    74                 : JSVariableObjectData(&functionBody->generatedBytecode().symbolTable(), registers)
    75                 , functionBody(functionBody)
     73            JSActivationData(PassRefPtr<FunctionExecutable> functionExecutable, Register* registers)
     74                : JSVariableObjectData(&functionExecutable->generatedBytecode().symbolTable(), registers)
     75                , functionExecutable(functionExecutable)
    7676            {
    7777            }
    7878
    79             RefPtr<FunctionBodyNode> functionBody;
     79            RefPtr<FunctionExecutable> functionExecutable;
    8080        };
    8181       
  • trunk/JavaScriptCore/runtime/JSFunction.cpp

    r47236 r47412  
    4848inline bool JSFunction::isHostFunction() const
    4949{
    50     return m_body && m_body->isHostFunction();
     50    return m_executable && m_executable->isHostFunction();
    5151}
    5252
     
    6565    : Base(&exec->globalData(), structure, name)
    6666#if ENABLE(JIT)
    67     , m_body(FunctionBodyNode::createNativeThunk(&exec->globalData()))
     67    , m_executable(FunctionExecutable::createNativeThunk(exec))
    6868#endif
    6969{
     
    7878}
    7979
    80 JSFunction::JSFunction(ExecState* exec, const Identifier& name, PassRefPtr<FunctionBodyNode> body, ScopeChainNode* scopeChainNode)
    81     : Base(&exec->globalData(), exec->lexicalGlobalObject()->functionStructure(), name)
    82     , m_body(body)
     80JSFunction::JSFunction(ExecState* exec, PassRefPtr<FunctionExecutable> executable, ScopeChainNode* scopeChainNode)
     81    : Base(&exec->globalData(), exec->lexicalGlobalObject()->functionStructure(), executable->name())
     82    , m_executable(executable)
    8383{
    8484    setScopeChain(scopeChainNode);
     
    9191    // this memory is freed and may be reused (potentially for another, different JSFunction).
    9292#if ENABLE(JIT_OPTIMIZE_CALL)
    93     if (m_body && m_body->isGenerated())
    94         m_body->generatedBytecode().unlinkCallers();
     93    if (m_executable && m_executable->isGenerated())
     94        m_executable->generatedBytecode().unlinkCallers();
    9595#endif
    9696    if (!isHostFunction())
     
    101101{
    102102    Base::markChildren(markStack);
    103     m_body->markAggregate(markStack);
     103    m_executable->markAggregate(markStack);
    104104    if (!isHostFunction())
    105105        scopeChain().markAggregate(markStack);
     
    112112        return CallTypeHost;
    113113    }
    114     callData.js.functionBody = m_body.get();
     114    callData.js.functionExecutable = m_executable.get();
    115115    callData.js.scopeChain = scopeChain().node();
    116116    return CallTypeJS;
     
    120120{
    121121    ASSERT(!isHostFunction());
    122     return exec->interpreter()->execute(m_body.get(), exec, this, thisValue.toThisObject(exec), args, scopeChain().node(), exec->exceptionSlot());
     122    return exec->interpreter()->execute(m_executable.get(), exec, this, thisValue.toThisObject(exec), args, scopeChain().node(), exec->exceptionSlot());
    123123}
    124124
     
    141141    JSFunction* thisObj = asFunction(slot.slotBase());
    142142    ASSERT(!thisObj->isHostFunction());
    143     return jsNumber(exec, thisObj->m_body->parameterCount());
     143    return jsNumber(exec, thisObj->m_executable->parameterCount());
    144144}
    145145
     
    205205    if (isHostFunction())
    206206        return ConstructTypeNone;
    207     constructData.js.functionBody = m_body.get();
     207    constructData.js.functionExecutable = m_executable.get();
    208208    constructData.js.scopeChain = scopeChain().node();
    209209    return ConstructTypeJS;
     
    221221    JSObject* thisObj = new (exec) JSObject(structure);
    222222
    223     JSValue result = exec->interpreter()->execute(m_body.get(), exec, this, thisObj, args, scopeChain().node(), exec->exceptionSlot());
     223    JSValue result = exec->interpreter()->execute(m_executable.get(), exec, this, thisObj, args, scopeChain().node(), exec->exceptionSlot());
    224224    if (exec->hadException() || !result.isObject())
    225225        return thisObj;
     
    227227}
    228228
    229 void JSFunction::setBody(PassRefPtr<FunctionBodyNode> body)
    230 {
    231     m_body = body;
    232 }
    233 
    234229} // namespace JSC
  • trunk/JavaScriptCore/runtime/JSFunction.h

    r47236 r47412  
    2525#define JSFunction_h
    2626
     27#include "Executable.h"
    2728#include "InternalFunction.h"
    2829
    2930namespace JSC {
    3031
    31     class FunctionBodyNode;
    3232    class FunctionPrototype;
    3333    class JSActivation;
     
    4242    public:
    4343        JSFunction(ExecState*, PassRefPtr<Structure>, int length, const Identifier&, NativeFunction);
    44         JSFunction(ExecState*, const Identifier&, PassRefPtr<FunctionBodyNode>, ScopeChainNode*);
     44        JSFunction(ExecState*, PassRefPtr<FunctionExecutable>, ScopeChainNode*);
    4545        virtual ~JSFunction();
    4646
     
    5151        ScopeChain& scope() { return scopeChain(); }
    5252
    53         void setBody(PassRefPtr<FunctionBodyNode>);
    54         FunctionBodyNode* body() const { return m_body.get(); }
     53        FunctionExecutable* executable() const { return m_executable.get(); }
    5554
    5655        static JS_EXPORTDATA const ClassInfo info;
     
    8786        static JSValue lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
    8887
    89         RefPtr<FunctionBodyNode> m_body;
     88        RefPtr<FunctionExecutable> m_executable;
    9089        ScopeChain& scopeChain()
    9190        {
     
    123122    }
    124123
     124    inline JSFunction* FunctionExecutable::make(ExecState* exec, ScopeChainNode* scopeChain)
     125    {
     126        return new (exec) JSFunction(exec, this, scopeChain);
     127    }
     128
    125129} // namespace JSC
    126130
  • trunk/JavaScriptCore/runtime/JSGlobalData.cpp

    r47304 r47412  
    145145    , head(0)
    146146    , dynamicGlobalObject(0)
    147     , scopeNodeBeingReparsed(0)
     147    , functionCodeBlockBeingReparsed(0)
    148148    , firstStringifierToMark(0)
    149149    , markStack(vptrSet.jsArrayVPtr)
     
    238238        initializingLazyNumericCompareFunction = true;
    239239        RefPtr<FunctionBodyNode> functionBody = parser->parseFunctionFromGlobalCode(exec, 0, makeSource(UString("(function (v1, v2) { return v1 - v2; })")), 0, 0);
    240         lazyNumericCompareFunction = functionBody->bytecode(exec->scopeChain()).instructions();
     240        FunctionExecutable function(functionBody->ident(), functionBody.get());
     241        lazyNumericCompareFunction = function.bytecode(exec->scopeChain()).instructions();
    241242        initializingLazyNumericCompareFunction = false;
    242243    }
  • trunk/JavaScriptCore/runtime/JSGlobalData.h

    r47022 r47412  
    4646namespace JSC {
    4747
     48    class CodeBlock;
    4849    class CommonIdentifiers;
    49     class FunctionBodyNode;
    5050    class IdentifierTable;
    5151    class Interpreter;
     
    5454    class Lexer;
    5555    class Parser;
    56     class ScopeNode;
    5756    class Stringifier;
    5857    class Structure;
     
    146145        HashSet<JSObject*> arrayVisitedElements;
    147146
    148         ScopeNode* scopeNodeBeingReparsed;
     147        CodeBlock* functionCodeBlockBeingReparsed;
    149148        Stringifier* firstStringifierToMark;
    150149
Note: See TracChangeset for help on using the changeset viewer.