Title: [209353] trunk/Source/_javascript_Core
Revision
209353
Author
[email protected]
Date
2016-12-05 14:46:06 -0800 (Mon, 05 Dec 2016)

Log Message

ScriptExecutable should not contain a copy of firstLine and startColumn
https://bugs.webkit.org/show_bug.cgi?id=165415

Reviewed by Keith Miller.

We already have this data in SourceCode.

It's super confusing to have two copies of this data, where one is
allowed to mutate. In reality, your line and column number never change.

* bytecode/UnlinkedFunctionExecutable.cpp:
(JSC::UnlinkedFunctionExecutable::link):
* runtime/CodeCache.cpp:
(JSC::CodeCache::getUnlinkedGlobalCodeBlock):
* runtime/CodeCache.h:
(JSC::generateUnlinkedCodeBlock):
* runtime/FunctionExecutable.cpp:
(JSC::FunctionExecutable::FunctionExecutable):
* runtime/FunctionExecutable.h:
* runtime/ScriptExecutable.cpp:
(JSC::ScriptExecutable::ScriptExecutable):
(JSC::ScriptExecutable::newCodeBlockFor):
* runtime/ScriptExecutable.h:
(JSC::ScriptExecutable::firstLine):
(JSC::ScriptExecutable::startColumn):
(JSC::ScriptExecutable::recordParse):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (209352 => 209353)


--- trunk/Source/_javascript_Core/ChangeLog	2016-12-05 22:42:28 UTC (rev 209352)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-12-05 22:46:06 UTC (rev 209353)
@@ -1,3 +1,32 @@
+2016-12-05  Geoffrey Garen  <[email protected]>
+
+        ScriptExecutable should not contain a copy of firstLine and startColumn
+        https://bugs.webkit.org/show_bug.cgi?id=165415
+
+        Reviewed by Keith Miller.
+
+        We already have this data in SourceCode.
+
+        It's super confusing to have two copies of this data, where one is
+        allowed to mutate. In reality, your line and column number never change.
+
+        * bytecode/UnlinkedFunctionExecutable.cpp:
+        (JSC::UnlinkedFunctionExecutable::link):
+        * runtime/CodeCache.cpp:
+        (JSC::CodeCache::getUnlinkedGlobalCodeBlock):
+        * runtime/CodeCache.h:
+        (JSC::generateUnlinkedCodeBlock):
+        * runtime/FunctionExecutable.cpp:
+        (JSC::FunctionExecutable::FunctionExecutable):
+        * runtime/FunctionExecutable.h:
+        * runtime/ScriptExecutable.cpp:
+        (JSC::ScriptExecutable::ScriptExecutable):
+        (JSC::ScriptExecutable::newCodeBlockFor):
+        * runtime/ScriptExecutable.h:
+        (JSC::ScriptExecutable::firstLine):
+        (JSC::ScriptExecutable::startColumn):
+        (JSC::ScriptExecutable::recordParse):
+
 2016-12-05  Caitlin Potter  <[email protected]>
 
         [JSC] report unexpected token when "async" is followed by identifier 

Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp (209352 => 209353)


--- trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp	2016-12-05 22:42:28 UTC (rev 209352)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp	2016-12-05 22:46:06 UTC (rev 209353)
@@ -159,7 +159,7 @@
         }
     }
 
-    FunctionExecutable* result = FunctionExecutable::create(vm, code, this, firstLine, firstLine + lineCount, startColumn, endColumn, intrinsic);
+    FunctionExecutable* result = FunctionExecutable::create(vm, code, this, firstLine + lineCount, endColumn, intrinsic);
     if (overrideLineNumber)
         result->setOverrideLineNumber(*overrideLineNumber);
 

Modified: trunk/Source/_javascript_Core/runtime/CodeCache.cpp (209352 => 209353)


--- trunk/Source/_javascript_Core/runtime/CodeCache.cpp	2016-12-05 22:42:28 UTC (rev 209352)
+++ trunk/Source/_javascript_Core/runtime/CodeCache.cpp	2016-12-05 22:46:06 UTC (rev 209353)
@@ -65,7 +65,7 @@
         unsigned startColumn = unlinkedCodeBlock->startColumn() + source.startColumn();
         bool endColumnIsOnStartLine = !lineCount;
         unsigned endColumn = unlinkedCodeBlock->endColumn() + (endColumnIsOnStartLine ? startColumn : 1);
-        executable->recordParse(unlinkedCodeBlock->codeFeatures(), unlinkedCodeBlock->hasCapturedVariables(), source.firstLine(), source.firstLine() + lineCount, startColumn, endColumn);
+        executable->recordParse(unlinkedCodeBlock->codeFeatures(), unlinkedCodeBlock->hasCapturedVariables(), source.firstLine() + lineCount, endColumn);
         source.provider()->setSourceURLDirective(unlinkedCodeBlock->sourceURLDirective());
         source.provider()->setSourceMappingURLDirective(unlinkedCodeBlock->sourceMappingURLDirective());
         return unlinkedCodeBlock;

Modified: trunk/Source/_javascript_Core/runtime/CodeCache.h (209352 => 209353)


--- trunk/Source/_javascript_Core/runtime/CodeCache.h	2016-12-05 22:42:28 UTC (rev 209352)
+++ trunk/Source/_javascript_Core/runtime/CodeCache.h	2016-12-05 22:46:06 UTC (rev 209353)
@@ -243,7 +243,7 @@
     unsigned unlinkedEndColumn = rootNode->endColumn();
     unsigned endColumn = unlinkedEndColumn + (endColumnIsOnStartLine ? startColumn : 1);
     unsigned arrowContextFeature = executable->isArrowFunctionContext() ? ArrowFunctionContextFeature : 0;
-    executable->recordParse(rootNode->features() | arrowContextFeature, rootNode->hasCapturedVariables(), rootNode->firstLine(), rootNode->lastLine(), startColumn, endColumn);
+    executable->recordParse(rootNode->features() | arrowContextFeature, rootNode->hasCapturedVariables(), rootNode->lastLine(), endColumn);
 
     UnlinkedCodeBlockType* unlinkedCodeBlock = UnlinkedCodeBlockType::create(&vm, executable->executableInfo(), debuggerMode);
     unlinkedCodeBlock->recordParse(rootNode->features(), rootNode->hasCapturedVariables(), lineCount, unlinkedEndColumn);

Modified: trunk/Source/_javascript_Core/runtime/FunctionExecutable.cpp (209352 => 209353)


--- trunk/Source/_javascript_Core/runtime/FunctionExecutable.cpp	2016-12-05 22:42:28 UTC (rev 209352)
+++ trunk/Source/_javascript_Core/runtime/FunctionExecutable.cpp	2016-12-05 22:46:06 UTC (rev 209353)
@@ -41,17 +41,14 @@
 
 const ClassInfo FunctionExecutable::s_info = { "FunctionExecutable", &ScriptExecutable::s_info, 0, CREATE_METHOD_TABLE(FunctionExecutable) };
 
-FunctionExecutable::FunctionExecutable(VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, unsigned firstLine, unsigned lastLine, unsigned startColumn, unsigned endColumn, Intrinsic intrinsic)
+FunctionExecutable::FunctionExecutable(VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, unsigned lastLine, unsigned endColumn, Intrinsic intrinsic)
     : ScriptExecutable(vm.functionExecutableStructure.get(), vm, source, unlinkedExecutable->isInStrictContext(), unlinkedExecutable->derivedContextType(), false, EvalContextType::None, intrinsic)
     , m_unlinkedExecutable(vm, this, unlinkedExecutable)
 {
     RELEASE_ASSERT(!source.isNull());
     ASSERT(source.length());
-    m_firstLine = firstLine;
     m_lastLine = lastLine;
-    ASSERT(startColumn != UINT_MAX);
     ASSERT(endColumn != UINT_MAX);
-    m_startColumn = startColumn;
     m_endColumn = endColumn;
     m_parametersStartOffset = unlinkedExecutable->parametersStartOffset();
     m_typeProfilingStartOffset = unlinkedExecutable->typeProfilingStartOffset();

Modified: trunk/Source/_javascript_Core/runtime/FunctionExecutable.h (209352 => 209353)


--- trunk/Source/_javascript_Core/runtime/FunctionExecutable.h	2016-12-05 22:42:28 UTC (rev 209352)
+++ trunk/Source/_javascript_Core/runtime/FunctionExecutable.h	2016-12-05 22:46:06 UTC (rev 209353)
@@ -38,9 +38,9 @@
 
     static FunctionExecutable* create(
         VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, 
-        unsigned firstLine, unsigned lastLine, unsigned startColumn, unsigned endColumn, Intrinsic intrinsic)
+        unsigned lastLine, unsigned endColumn, Intrinsic intrinsic)
     {
-        FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>(vm.heap)) FunctionExecutable(vm, source, unlinkedExecutable, firstLine, lastLine, startColumn, endColumn, intrinsic);
+        FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>(vm.heap)) FunctionExecutable(vm, source, unlinkedExecutable, lastLine, endColumn, intrinsic);
         executable->finishCreation(vm);
         return executable;
     }
@@ -172,8 +172,8 @@
 private:
     friend class ExecutableBase;
     FunctionExecutable(
-        VM&, const SourceCode&, UnlinkedFunctionExecutable*, unsigned firstLine, 
-        unsigned lastLine, unsigned startColumn, unsigned endColumn, Intrinsic);
+        VM&, const SourceCode&, UnlinkedFunctionExecutable*,
+        unsigned lastLine, unsigned endColumn, Intrinsic);
     
     void finishCreation(VM&);
 

Modified: trunk/Source/_javascript_Core/runtime/ScriptExecutable.cpp (209352 => 209353)


--- trunk/Source/_javascript_Core/runtime/ScriptExecutable.cpp	2016-12-05 22:42:28 UTC (rev 209352)
+++ trunk/Source/_javascript_Core/runtime/ScriptExecutable.cpp	2016-12-05 22:46:06 UTC (rev 209353)
@@ -57,9 +57,7 @@
     , m_derivedContextType(static_cast<unsigned>(derivedContextType))
     , m_evalContextType(static_cast<unsigned>(evalContextType))
     , m_overrideLineNumber(-1)
-    , m_firstLine(-1)
     , m_lastLine(-1)
-    , m_startColumn(UINT_MAX)
     , m_endColumn(UINT_MAX)
     , m_typeProfilingStartOffset(UINT_MAX)
     , m_typeProfilingEndOffset(UINT_MAX)
@@ -178,7 +176,6 @@
     auto throwScope = DECLARE_THROW_SCOPE(*vm);
 
     ASSERT(vm->heap.isDeferred());
-    ASSERT(startColumn() != UINT_MAX);
     ASSERT(endColumn() != UINT_MAX);
 
     if (classInfo() == EvalExecutable::info()) {
@@ -198,7 +195,7 @@
         RELEASE_ASSERT(!function);
         return ProgramCodeBlock::create(vm,
             executable, executable->m_unlinkedProgramCodeBlock.get(), scope,
-            executable->source().provider(), executable->source().startColumn());
+            executable->source().provider(), startColumn());
     }
 
     if (classInfo() == ModuleProgramExecutable::info()) {
@@ -208,7 +205,7 @@
         RELEASE_ASSERT(!function);
         return ModuleProgramCodeBlock::create(vm,
             executable, executable->m_unlinkedModuleProgramCodeBlock.get(), scope,
-            executable->source().provider(), executable->source().startColumn());
+            executable->source().provider(), startColumn());
     }
 
     RELEASE_ASSERT(classInfo() == FunctionExecutable::info());
@@ -224,8 +221,8 @@
             executable->parseMode());
     recordParse(
         executable->m_unlinkedExecutable->features(), 
-        executable->m_unlinkedExecutable->hasCapturedVariables(), firstLine(), 
-        lastLine(), startColumn(), endColumn()); 
+        executable->m_unlinkedExecutable->hasCapturedVariables(),
+        lastLine(), endColumn()); 
     if (!unlinkedCodeBlock) {
         exception = throwException(
             globalObject->globalExec(), throwScope,
@@ -233,12 +230,8 @@
         return nullptr;
     }
 
-    SourceProvider* provider = executable->source().provider();
-    unsigned sourceOffset = executable->source().startOffset();
-    unsigned startColumn = executable->source().startColumn();
-
-    return FunctionCodeBlock::create(vm,
-        executable, unlinkedCodeBlock, scope, provider, sourceOffset, startColumn);
+    return FunctionCodeBlock::create(vm, executable, unlinkedCodeBlock, scope, 
+        source().provider(), source().startOffset(), startColumn());
 }
 
 CodeBlock* ScriptExecutable::newReplacementCodeBlockFor(

Modified: trunk/Source/_javascript_Core/runtime/ScriptExecutable.h (209352 => 209353)


--- trunk/Source/_javascript_Core/runtime/ScriptExecutable.h	2016-12-05 22:42:28 UTC (rev 209352)
+++ trunk/Source/_javascript_Core/runtime/ScriptExecutable.h	2016-12-05 22:46:06 UTC (rev 209353)
@@ -41,12 +41,12 @@
     const SourceCode& source() const { return m_source; }
     intptr_t sourceID() const { return m_source.providerID(); }
     const String& sourceURL() const { return m_source.provider()->url(); }
-    int firstLine() const { return m_firstLine; }
+    int firstLine() const { return m_source.firstLine(); }
     void setOverrideLineNumber(int overrideLineNumber) { m_overrideLineNumber = overrideLineNumber; }
     bool hasOverrideLineNumber() const { return m_overrideLineNumber != -1; }
     int overrideLineNumber() const { return m_overrideLineNumber; }
     int lastLine() const { return m_lastLine; }
-    unsigned startColumn() const { return m_startColumn; }
+    unsigned startColumn() const { return m_source.startColumn(); }
     unsigned endColumn() const { return m_endColumn; }
     unsigned typeProfilingStartOffset() const { return m_typeProfilingStartOffset; }
     unsigned typeProfilingEndOffset() const { return m_typeProfilingEndOffset; }
@@ -79,14 +79,11 @@
         
     DECLARE_EXPORT_INFO;
 
-    void recordParse(CodeFeatures features, bool hasCapturedVariables, int firstLine, int lastLine, unsigned startColumn, unsigned endColumn)
+    void recordParse(CodeFeatures features, bool hasCapturedVariables, int lastLine, unsigned endColumn)
     {
         m_features = features;
         m_hasCapturedVariables = hasCapturedVariables;
-        m_firstLine = firstLine;
         m_lastLine = lastLine;
-        ASSERT(startColumn != UINT_MAX);
-        m_startColumn = startColumn;
         ASSERT(endColumn != UINT_MAX);
         m_endColumn = endColumn;
     }
@@ -135,9 +132,7 @@
     unsigned m_evalContextType : 2; // EvalContextType
 
     int m_overrideLineNumber;
-    int m_firstLine;
     int m_lastLine;
-    unsigned m_startColumn;
     unsigned m_endColumn;
     unsigned m_typeProfilingStartOffset;
     unsigned m_typeProfilingEndOffset;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to