source: webkit/trunk/JavaScriptCore/kjs/NodeInfo.h@ 35900

Last change on this file since 35900 was 35593, checked in by [email protected], 17 years ago

2008-08-06 Cameron Zwarich <[email protected]>

Reviewed by Maciej.

Bug 20286: Load constants all at once instead of using op_load
<https://bugs.webkit.org/show_bug.cgi?id=20286>

Load constants all at once into temporary registers instead of using
individual instances of op_load.

This is a 2.6% speedup on SunSpider.

JavaScriptCore:

  • JavaScriptCore.exp:
  • VM/CodeBlock.cpp: (KJS::CodeBlock::dump): (KJS::CodeBlock::mark):
  • VM/CodeBlock.h:
  • VM/CodeGenerator.cpp: (KJS::CodeGenerator::CodeGenerator): (KJS::CodeGenerator::newTemporary): (KJS::CodeGenerator::addConstant): (KJS::CodeGenerator::addUnexpectedConstant): (KJS::CodeGenerator::emitLoad): (KJS::CodeGenerator::emitUnexpectedLoad): (KJS::CodeGenerator::emitNewError):
  • VM/CodeGenerator.h:
  • VM/Machine.cpp: (KJS::slideRegisterWindowForCall): (KJS::Machine::unwindCallFrame): (KJS::Machine::throwException): (KJS::Machine::execute): (KJS::Machine::privateExecute):
  • VM/Machine.h:
  • VM/Opcode.h:
  • VM/RegisterID.h: (KJS::RegisterID::RegisterID): (KJS::RegisterID::makeConstant): (KJS::RegisterID::isTemporary):
  • kjs/NodeInfo.h:
  • kjs/Parser.cpp: (KJS::Parser::didFinishParsing):
  • kjs/Parser.h: (KJS::Parser::parse):
  • kjs/grammar.y:
  • kjs/nodes.cpp: (KJS::NullNode::emitCode): (KJS::BooleanNode::emitCode): (KJS::NumberNode::emitCode): (KJS::StringNode::emitCode): (KJS::ArrayNode::emitCode): (KJS::DeleteResolveNode::emitCode): (KJS::DeleteValueNode::emitCode): (KJS::VoidNode::emitCode): (KJS::ConstDeclNode::emitCodeSingle): (KJS::ReturnNode::emitCode): (KJS::ScopeNode::ScopeNode): (KJS::ProgramNode::ProgramNode): (KJS::ProgramNode::create): (KJS::EvalNode::EvalNode): (KJS::EvalNode::create): (KJS::FunctionBodyNode::FunctionBodyNode): (KJS::FunctionBodyNode::create): (KJS::FunctionBodyNode::emitCode):
  • kjs/nodes.h: (KJS::ScopeNode::neededConstants):

LayoutTests:

  • fast/js/constant-count-expected.txt: Added.
  • fast/js/constant-count.html: Added.
  • fast/js/deep-recursion-test.html:
  • fast/js/resources/constant-count.js: Added.
  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1/*
2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 *
18 */
19
20#ifndef NodeInfo_h
21#define NodeInfo_h
22
23#include "nodes.h"
24#include "Parser.h"
25
26namespace KJS {
27
28 typedef unsigned int FeatureInfo;
29
30 const FeatureInfo NoFeatures = 0;
31 const FeatureInfo EvalFeature = 1 << 0;
32 const FeatureInfo ClosureFeature = 1 << 1;
33 const FeatureInfo AssignFeature = 1 << 2;
34
35 template <typename T> struct NodeFeatureInfo {
36 T m_node;
37 FeatureInfo m_featureInfo;
38 int m_numConstants;
39 };
40
41 typedef NodeFeatureInfo<FuncExprNode*> FuncExprNodeInfo;
42 typedef NodeFeatureInfo<ExpressionNode*> ExpressionNodeInfo;
43 typedef NodeFeatureInfo<ArgumentsNode*> ArgumentsNodeInfo;
44 typedef NodeFeatureInfo<ConstDeclNode*> ConstDeclNodeInfo;
45 typedef NodeFeatureInfo<PropertyNode*> PropertyNodeInfo;
46 typedef NodeFeatureInfo<PropertyList> PropertyListInfo;
47 typedef NodeFeatureInfo<ElementList> ElementListInfo;
48 typedef NodeFeatureInfo<ArgumentList> ArgumentListInfo;
49
50 template <typename T> struct NodeDeclarationInfo {
51 T m_node;
52 ParserRefCountedData<DeclarationStacks::VarStack>* m_varDeclarations;
53 ParserRefCountedData<DeclarationStacks::FunctionStack>* m_funcDeclarations;
54 FeatureInfo m_featureInfo;
55 int m_numConstants;
56 };
57
58 typedef NodeDeclarationInfo<StatementNode*> StatementNodeInfo;
59 typedef NodeDeclarationInfo<CaseBlockNode*> CaseBlockNodeInfo;
60 typedef NodeDeclarationInfo<CaseClauseNode*> CaseClauseNodeInfo;
61 typedef NodeDeclarationInfo<SourceElements*> SourceElementsInfo;
62 typedef NodeDeclarationInfo<ClauseList> ClauseListInfo;
63 typedef NodeDeclarationInfo<ExpressionNode*> VarDeclListInfo;
64 typedef NodeDeclarationInfo<ConstDeclList> ConstDeclListInfo;
65
66} // namespace KJS
67
68#endif // NodeInfo_h
Note: See TracBrowser for help on using the repository browser.