Changeset 47412 in webkit for trunk/JavaScriptCore/parser
- Timestamp:
- Aug 17, 2009, 10:34:52 PM (16 years ago)
- Location:
- trunk/JavaScriptCore/parser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/parser/Nodes.cpp
r47304 r47412 1825 1825 } 1826 1826 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 1838 1827 // ------------------------------ ScopeNode ----------------------------- 1839 1828 … … 1893 1882 } 1894 1883 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 #endif1918 1919 1884 // ------------------------------ EvalNode ----------------------------- 1920 1885 … … 1947 1912 return 0; 1948 1913 } 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 that1984 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 #endif1997 1914 1998 1915 // ------------------------------ FunctionBodyNode ----------------------------- … … 2038 1955 } 2039 1956 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 #endif2056 2057 bool FunctionBodyNode::isHostFunction() const2058 {2059 return m_code && m_code->codeType() == NativeCode;2060 }2061 2062 1957 FunctionBodyNode* FunctionBodyNode::create(JSGlobalData* globalData) 2063 1958 { … … 2076 1971 } 2077 1972 2078 void FunctionBodyNode:: generateBytecode(ScopeChainNode* scopeChainNode)1973 void FunctionBodyNode::reparseDataIfNecessary(ScopeChainNode* scopeChainNode) 2079 1974 { 2080 1975 // This branch is only necessary since you can still create a non-stub FunctionBodyNode by … … 2083 1978 scopeChainNode->globalData->parser->reparseInPlace(scopeChainNode->globalData, this); 2084 1979 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 #endif2107 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;2122 1980 } 2123 1981 … … 2157 2015 } 2158 2016 2159 JSFunction* FunctionBodyNode::make(ExecState* exec, ScopeChainNode* scopeChain)2160 {2161 return new (exec) JSFunction(exec, m_ident, this, scopeChain);2162 }2163 2164 2017 // ------------------------------ FuncDeclNode --------------------------------- 2165 2018 -
trunk/JavaScriptCore/parser/Nodes.h
r47259 r47412 40 40 41 41 class ArgumentListNode; 42 class BytecodeGenerator; 42 43 class CodeBlock; 43 class BytecodeGenerator; 44 class EvalCodeBlock; 45 class EvalExecutable; 44 46 class FuncDeclNode; 45 class EvalCodeBlock; 47 class FunctionBodyNode; 48 class FunctionCodeBlock; 46 49 class JSFunction; 47 50 class ProgramCodeBlock; 51 class ProgramExecutable; 48 52 class PropertyListNode; 49 53 class ReadModifyResolveNode; … … 1391 1395 int m_numConstants; 1392 1396 StatementVector m_children; 1393 1394 void markAggregate(MarkStack&);1395 1397 }; 1396 1398 … … 1438 1440 } 1439 1441 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 #endif1459 1460 1442 protected: 1461 1443 void setSource(const SourceCode& source) { m_source = source; } 1462 1463 #if ENABLE(JIT)1464 JITCode m_jitCode;1465 #endif1466 1444 1467 1445 private: … … 1475 1453 static PassRefPtr<ProgramNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants); 1476 1454 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() 1478 1466 { 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(); 1482 1470 } 1483 1471 1484 #if ENABLE(JIT)1485 JITCode& jitCode(ScopeChainNode* scopeChain)1486 {1487 if (!m_jitCode)1488 generateJITCode(scopeChain);1489 return m_jitCode;1490 }1491 #endif1492 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 #endif1502 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 #endif1529 1530 1472 private: 1531 1473 EvalNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants); 1532 1474 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); 1541 1476 }; 1542 1477 … … 1544 1479 friend class JIT; 1545 1480 public: 1546 #if ENABLE(JIT)1547 static PassRefPtr<FunctionBodyNode> createNativeThunk(JSGlobalData*);1548 #endif1549 1481 static FunctionBodyNode* create(JSGlobalData*); 1550 1482 static PassRefPtr<FunctionBodyNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants); … … 1558 1490 virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); 1559 1491 1560 bool isGenerated() const1561 {1562 return m_code;1563 }1564 1565 bool isHostFunction() const;1566 1567 virtual void markAggregate(MarkStack&);1568 1569 1492 void finishParsing(const SourceCode&, ParameterNode*, const Identifier& ident); 1570 1493 void finishParsing(Identifier* parameters, size_t parameterCount, const Identifier& ident); 1571 1494 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 #endif1583 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 1598 1495 const Identifier& ident() { return m_ident; } 1599 1496 1600 JSFunction* make(ExecState*, ScopeChainNode*);1497 void reparseDataIfNecessary(ScopeChainNode* scopeChainNode); 1601 1498 1602 1499 private: 1603 1500 FunctionBodyNode(JSGlobalData*); 1604 1501 FunctionBodyNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants); 1605 1606 void generateBytecode(ScopeChainNode*);1607 #if ENABLE(JIT)1608 void generateJITCode(ScopeChainNode*);1609 #endif1610 1502 Identifier m_ident; 1611 1503 Identifier* m_parameters; 1612 1504 size_t m_parameterCount; 1613 OwnPtr<CodeBlock> m_code;1614 1505 }; 1615 1506
Note:
See TracChangeset
for help on using the changeset viewer.