source: webkit/trunk/JavaScriptCore/kjs/Parser.h@ 37088

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

2008-09-28 Cameron Zwarich <[email protected]>

Reviewed by Maciej Stachowiak.

Bug 21200: Allow direct access to 'arguments' without using op_resolve
<https://bugs.webkit.org/show_bug.cgi?id=21200>

Allow fast access to the 'arguments' object by adding an extra slot to
the callframe to store it.

  • JavaScriptCore.exp:
  • VM/CTI.cpp: (JSC::CTI::privateCompileMainPass):
  • VM/CodeBlock.cpp: (JSC::CodeBlock::dump):
  • VM/CodeGenerator.cpp: (JSC::CodeGenerator::CodeGenerator): (JSC::CodeGenerator::registerFor):
  • VM/CodeGenerator.h: (JSC::CodeGenerator::registerFor):
  • VM/Machine.cpp: (JSC::Machine::initializeCallFrame): (JSC::Machine::dumpRegisters): (JSC::Machine::privateExecute): (JSC::Machine::retrieveArguments): (JSC::Machine::cti_op_call_JSFunction): (JSC::Machine::cti_op_create_arguments): (JSC::Machine::cti_op_construct_JSConstruct):
  • VM/Machine.h:
  • VM/Opcode.h:
  • VM/RegisterFile.h: (JSC::RegisterFile::):
  • kjs/JSActivation.cpp: (JSC::JSActivation::mark): (JSC::JSActivation::argumentsGetter):
  • kjs/JSActivation.h: (JSC::JSActivation::JSActivationData::JSActivationData):
  • kjs/NodeInfo.h:
  • kjs/Parser.cpp: (JSC::Parser::didFinishParsing):
  • kjs/Parser.h: (JSC::Parser::parse):
  • kjs/grammar.y:
  • kjs/nodes.cpp: (JSC::ScopeNode::ScopeNode): (JSC::ProgramNode::ProgramNode): (JSC::ProgramNode::create): (JSC::EvalNode::EvalNode): (JSC::EvalNode::create): (JSC::FunctionBodyNode::FunctionBodyNode): (JSC::FunctionBodyNode::create):
  • kjs/nodes.h: (JSC::ScopeNode::usesArguments):
  • Property svn:eol-style set to native
File size: 4.2 KB
Line 
1/*
2 * Copyright (C) 1999-2001 Harri Porten ([email protected])
3 * Copyright (C) 2001 Peter Kelly ([email protected])
4 * Copyright (C) 2003, 2006, 2007, 2008 Apple Inc. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#ifndef Parser_h
24#define Parser_h
25
26#include "SourceProvider.h"
27#include "nodes.h"
28#include <wtf/Forward.h>
29#include <wtf/Noncopyable.h>
30#include <wtf/OwnPtr.h>
31#include <wtf/RefPtr.h>
32
33namespace JSC {
34
35 class FunctionBodyNode;
36 class ProgramNode;
37 class UString;
38
39 template <typename T>
40 struct ParserRefCountedData : ParserRefCounted {
41 ParserRefCountedData(JSGlobalData* globalData)
42 : ParserRefCounted(globalData)
43 {
44 }
45
46 T data;
47 };
48
49 class Parser : Noncopyable {
50 public:
51 template <class ParsedNode>
52 PassRefPtr<ParsedNode> parse(ExecState*, const UString& sourceURL, int startingLineNumber, PassRefPtr<SourceProvider> source,
53 int* sourceId = 0, int* errLine = 0, UString* errMsg = 0);
54
55 UString sourceURL() const { return m_sourceURL; }
56 int sourceId() const { return m_sourceId; }
57
58 void didFinishParsing(SourceElements*, ParserRefCountedData<DeclarationStacks::VarStack>*,
59 ParserRefCountedData<DeclarationStacks::FunctionStack>*, bool usesEval, bool needsClosure, bool usesArguments, int lastLine, int numConstants);
60
61 private:
62 friend class JSGlobalData;
63 Parser();
64
65 void parse(ExecState*, const UString& sourceURL, int startingLineNumber, PassRefPtr<SourceProvider> source,
66 int* sourceId, int* errLine, UString* errMsg);
67
68 UString m_sourceURL;
69 int m_sourceId;
70 RefPtr<SourceElements> m_sourceElements;
71 RefPtr<ParserRefCountedData<DeclarationStacks::VarStack> > m_varDeclarations;
72 RefPtr<ParserRefCountedData<DeclarationStacks::FunctionStack> > m_funcDeclarations;
73 bool m_usesEval;
74 bool m_needsClosure;
75 bool m_usesArguments;
76 int m_lastLine;
77 int m_numConstants;
78 };
79
80 template <class ParsedNode>
81 PassRefPtr<ParsedNode> Parser::parse(ExecState* exec, const UString& sourceURL, int startingLineNumber, PassRefPtr<SourceProvider> source,
82 int* sourceId, int* errLine, UString* errMsg)
83 {
84 m_sourceURL = sourceURL;
85 RefPtr<SourceProvider> sourceProvider = source;
86 parse(exec, sourceURL, startingLineNumber, sourceProvider.get(), sourceId, errLine, errMsg);
87 if (!m_sourceElements) {
88 m_sourceURL = UString();
89 return 0;
90 }
91 RefPtr<ParsedNode> node = ParsedNode::create(&exec->globalData(),
92 m_sourceElements.release().get(),
93 m_varDeclarations ? &m_varDeclarations->data : 0,
94 m_funcDeclarations ? &m_funcDeclarations->data : 0,
95 sourceProvider.get(),
96 m_usesEval,
97 m_needsClosure,
98 m_usesArguments,
99 m_numConstants);
100 m_varDeclarations = 0;
101 m_funcDeclarations = 0;
102 m_sourceURL = UString();
103 node->setLoc(startingLineNumber, m_lastLine);
104 return node.release();
105 }
106
107} // namespace JSC
108
109#endif // Parser_h
Note: See TracBrowser for help on using the repository browser.