X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/14957cd040308e3eeec43d26bae5d76da13fcd85..6fe7ccc865dc7d7541b93c5bcaf6368d2c98a174:/bytecompiler/BytecodeGenerator.h?ds=sidebyside diff --git a/bytecompiler/BytecodeGenerator.h b/bytecompiler/BytecodeGenerator.h index bc297ee..e58fcc7 100644 --- a/bytecompiler/BytecodeGenerator.h +++ b/bytecompiler/BytecodeGenerator.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2008, 2009, 2012 Apple Inc. All rights reserved. * Copyright (C) 2008 Cameron Zwarich * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ #define BytecodeGenerator_h #include "CodeBlock.h" -#include "HashTraits.h" +#include #include "Instruction.h" #include "Label.h" #include "LabelScope.h" @@ -47,6 +47,7 @@ namespace JSC { class Identifier; + class Label; class ScopeChainNode; class CallArguments { @@ -55,20 +56,27 @@ namespace JSC { RegisterID* thisRegister() { return m_argv[0].get(); } RegisterID* argumentRegister(unsigned i) { return m_argv[i + 1].get(); } - unsigned callFrame() { return thisRegister()->index() + count() + RegisterFile::CallFrameHeaderSize; } - unsigned count() { return m_argv.size(); } + unsigned registerOffset() { return m_argv.last()->index() + CallFrame::offsetFor(argumentCountIncludingThis()); } + unsigned argumentCountIncludingThis() { return m_argv.size(); } RegisterID* profileHookRegister() { return m_profileHookRegister.get(); } ArgumentsNode* argumentsNode() { return m_argumentsNode; } private: + void newArgument(BytecodeGenerator&); + RefPtr m_profileHookRegister; ArgumentsNode* m_argumentsNode; - Vector, 16> m_argv; + Vector, 8> m_argv; }; struct FinallyContext { - Label* finallyAddr; - RegisterID* retAddrDst; + StatementNode* finallyBlock; + unsigned scopeContextStackSize; + unsigned switchContextStackSize; + unsigned forInContextStackSize; + unsigned labelScopesSize; + int finallyDepth; + int dynamicScopeDepth; }; struct ControlFlowContext { @@ -89,13 +97,15 @@ namespace JSC { typedef DeclarationStacks::VarStack VarStack; typedef DeclarationStacks::FunctionStack FunctionStack; - static void setDumpsGeneratedCode(bool dumpsGeneratedCode); + JS_EXPORT_PRIVATE static void setDumpsGeneratedCode(bool dumpsGeneratedCode); static bool dumpsGeneratedCode(); - BytecodeGenerator(ProgramNode*, ScopeChainNode*, SymbolTable*, ProgramCodeBlock*); - BytecodeGenerator(FunctionBodyNode*, ScopeChainNode*, SymbolTable*, CodeBlock*); - BytecodeGenerator(EvalNode*, ScopeChainNode*, SymbolTable*, EvalCodeBlock*); + BytecodeGenerator(ProgramNode*, ScopeChainNode*, SymbolTable*, ProgramCodeBlock*, CompilationKind); + BytecodeGenerator(FunctionBodyNode*, ScopeChainNode*, SymbolTable*, CodeBlock*, CompilationKind); + BytecodeGenerator(EvalNode*, ScopeChainNode*, SymbolTable*, EvalCodeBlock*, CompilationKind); + ~BytecodeGenerator(); + JSGlobalData* globalData() const { return m_globalData; } const CommonIdentifiers& propertyNames() const { return *m_globalData->propertyNames; } @@ -108,8 +118,7 @@ namespace JSC { // require explicit reference counting. RegisterID* registerFor(const Identifier&); - // Returns the agument number if this is an argument, or 0 if not. - int argumentNumberFor(const Identifier&); + bool isArgumentNumber(const Identifier&, int); void setIsNumericCompareFunction(bool isNumericCompareFunction); @@ -121,9 +130,9 @@ namespace JSC { RegisterID* constRegisterFor(const Identifier&); // Searches the scope chain in an attempt to statically locate the requested - // property. Returns false if for any reason the property cannot be safely - // optimised at all. Otherwise it will return the index and depth of the - // VariableObject that defines the property. If the property cannot be found + // property. Returns false if for any reason the property cannot be safely + // optimised at all. Otherwise it will return the index and depth of the + // VariableObject that defines the property. If the property cannot be found // statically, depth will contain the depth of the scope chain where dynamic // lookup must begin. bool findScopedProperty(const Identifier&, int& index, size_t& depth, bool forWriting, bool& includesDynamicScopes, JSObject*& globalObject); @@ -271,7 +280,7 @@ namespace JSC { return dst; } - return PassRefPtr(emitNode(n)); + return emitNode(n); } RegisterID* emitLoad(RegisterID* dst, bool); @@ -313,6 +322,7 @@ namespace JSC { RegisterID* emitResolveBase(RegisterID* dst, const Identifier& property); RegisterID* emitResolveBaseForPut(RegisterID* dst, const Identifier& property); RegisterID* emitResolveWithBase(RegisterID* baseDst, RegisterID* propDst, const Identifier& property); + RegisterID* emitResolveWithThis(RegisterID* baseDst, RegisterID* propDst, const Identifier& property); void emitMethodCheck(); @@ -326,12 +336,11 @@ namespace JSC { RegisterID* emitPutByVal(RegisterID* base, RegisterID* property, RegisterID* value); RegisterID* emitDeleteByVal(RegisterID* dst, RegisterID* base, RegisterID* property); RegisterID* emitPutByIndex(RegisterID* base, unsigned index, RegisterID* value); - RegisterID* emitPutGetter(RegisterID* base, const Identifier& property, RegisterID* value); - RegisterID* emitPutSetter(RegisterID* base, const Identifier& property, RegisterID* value); + void emitPutGetterSetter(RegisterID* base, const Identifier& property, RegisterID* getter, RegisterID* setter); RegisterID* emitCall(RegisterID* dst, RegisterID* func, CallArguments&, unsigned divot, unsigned startOffset, unsigned endOffset); RegisterID* emitCallEval(RegisterID* dst, RegisterID* func, CallArguments&, unsigned divot, unsigned startOffset, unsigned endOffset); - RegisterID* emitCallVarargs(RegisterID* dst, RegisterID* func, RegisterID* thisRegister, RegisterID* argCount, unsigned divot, unsigned startOffset, unsigned endOffset); + RegisterID* emitCallVarargs(RegisterID* dst, RegisterID* func, RegisterID* thisRegister, RegisterID* arguments, RegisterID* firstFreeRegister, RegisterID* profileHookRegister, unsigned divot, unsigned startOffset, unsigned endOffset); RegisterID* emitLoadVarargs(RegisterID* argCountDst, RegisterID* thisRegister, RegisterID* args); RegisterID* emitReturn(RegisterID* src); @@ -342,6 +351,7 @@ namespace JSC { void emitToPrimitive(RegisterID* dst, RegisterID* src); PassRefPtr