Ignore:
Timestamp:
Mar 7, 2015, 2:10:10 PM (10 years ago)
Author:
[email protected]
Message:

The code to link FunctionExecutable is duplicated everywhere
https://bugs.webkit.org/show_bug.cgi?id=142436

Reviewed by Darin Adler.

Reduced code duplication by factoring out linkInsideExecutable and linkGlobalCode.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::CodeBlock): Calls linkInsideExecutable.

  • bytecode/UnlinkedCodeBlock.cpp:

(JSC::UnlinkedFunctionExecutable::linkInsideExecutable): Renamed from link. Now takes care of startOffset.
This change was needed to use this function in CodeBlock::CodeBlock. Also, this function no longer takes
lineOffset since this information is already stored in the source code.
(JSC::UnlinkedFunctionExecutable::linkGlobalCode): Extracted from FunctionExecutable::fromGlobalCode.

  • bytecode/UnlinkedCodeBlock.h:
  • generate-js-builtins: Calls linkGlobalCode.
  • runtime/Executable.cpp:

(JSC::ProgramExecutable::initializeGlobalProperties): Calls linkGlobalCode.
(JSC::FunctionExecutable::fromGlobalCode): Calls linkGlobalCode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/generate-js-builtins

    r163960 r181213  
    265265
    266266builtinsImplementation.write("""
    267 FunctionExecutable* createBuiltinExecutable(VM& vm, UnlinkedFunctionExecutable* unlinkedExecutable, const SourceCode& source)
    268 {
    269     unsigned lineCount = unlinkedExecutable->lineCount();
    270     unsigned startColumn = 1;
    271     unsigned sourceLength = unlinkedExecutable->sourceLength();
    272     bool endColumnIsOnStartLine = !lineCount;
    273     unsigned endColumnExcludingBraces = unlinkedExecutable->unlinkedBodyEndColumn() + (endColumnIsOnStartLine ? 0 : 1);
    274     unsigned startOffset = unlinkedExecutable->startOffset();
    275     unsigned startOffsetExcludingOpenBrace = startOffset + 1;
    276     unsigned endOffsetExcludingCloseBrace = startOffset + sourceLength - 1;
    277     SourceCode bodySource(source.provider(), startOffsetExcludingOpenBrace, endOffsetExcludingCloseBrace, 0, startColumn);
    278     return FunctionExecutable::create(vm, bodySource, unlinkedExecutable, 0, lineCount, startColumn, endColumnExcludingBraces, false);
    279 }
    280 
    281267#define JSC_DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \\
    282268FunctionExecutable* codeName##Generator(VM& vm) \\
    283269{ \\
    284     return createBuiltinExecutable(vm, vm.builtinExecutables()->codeName##Executable(), vm.builtinExecutables()->codeName##Source()); \\
     270    return vm.builtinExecutables()->codeName##Executable()->linkGlobalCode(vm, vm.builtinExecutables()->codeName##Source()); \\
    285271}
    286272
Note: See TracChangeset for help on using the changeset viewer.