From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- .../bytecompiler/BytecodeGenerator.h | 1017 ++++++++++++++------ 1 file changed, 744 insertions(+), 273 deletions(-) (limited to 'Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h') diff --git a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h index 4e9f213c9..06da7cb71 100644 --- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h +++ b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008, 2009, 2012, 2013 Apple Inc. All rights reserved. + * Copyright (C) 2008-2009, 2012-2016 Apple Inc. All rights reserved. * Copyright (C) 2008 Cameron Zwarich * Copyright (C) 2012 Igalia, S.L. * @@ -12,7 +12,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -28,34 +28,32 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef BytecodeGenerator_h -#define BytecodeGenerator_h +#pragma once #include "CodeBlock.h" -#include #include "Instruction.h" +#include "Interpreter.h" +#include "JSGeneratorFunction.h" #include "Label.h" #include "LabelScope.h" -#include "Interpreter.h" +#include "Nodes.h" #include "ParserError.h" #include "RegisterID.h" -#include "SymbolTable.h" -#include "Debugger.h" -#include "Nodes.h" #include "StaticPropertyAnalyzer.h" +#include "SymbolTable.h" +#include "TemplateRegistryKey.h" #include "UnlinkedCodeBlock.h" - #include - -#include +#include +#include #include +#include #include - namespace JSC { class Identifier; - class Label; + class JSTemplateRegistryKey; enum ExpectedFunction { NoExpectedFunction, @@ -63,132 +61,334 @@ namespace JSC { ExpectArrayConstructor }; + enum class DebuggableCall { Yes, No }; + enum class ThisResolutionType { Local, Scoped }; + class CallArguments { public: CallArguments(BytecodeGenerator&, ArgumentsNode*, unsigned additionalArguments = 0); RegisterID* thisRegister() { return m_argv[0].get(); } RegisterID* argumentRegister(unsigned i) { return m_argv[i + 1].get(); } - unsigned stackOffset() { return -m_argv[0]->index() + JSStack::CallFrameHeaderSize; } + unsigned stackOffset() { return -m_argv[0]->index() + CallFrame::headerSizeInRegisters; } unsigned argumentCountIncludingThis() { return m_argv.size() - m_padding; } - RegisterID* profileHookRegister() { return m_profileHookRegister.get(); } ArgumentsNode* argumentsNode() { return m_argumentsNode; } private: - RefPtr m_profileHookRegister; ArgumentsNode* m_argumentsNode; Vector, 8, UnsafeVectorOverflow> m_argv; unsigned m_padding; }; + // https://tc39.github.io/ecma262/#sec-completion-record-specification-type + // + // For the Break and Continue cases, instead of using the Break and Continue enum values + // below, we use the unique jumpID of the break and continue statement as the encoding + // for the CompletionType value. emitFinallyCompletion() uses this jumpID value later + // to determine the appropriate jump target to jump to after executing the relevant finally + // blocks. The jumpID is computed as: + // jumpID = bytecodeOffset (of the break/continue node) + CompletionType::NumberOfTypes. + // Hence, there won't be any collision between jumpIDs and CompletionType enums. + enum class CompletionType : int { + Normal, + Break, + Continue, + Return, + Throw, + + NumberOfTypes + }; + + inline CompletionType bytecodeOffsetToJumpID(unsigned offset) + { + int jumpIDAsInt = offset + static_cast(CompletionType::NumberOfTypes); + ASSERT(jumpIDAsInt >= static_cast(CompletionType::NumberOfTypes)); + return static_cast(jumpIDAsInt); + } + + struct FinallyJump { + FinallyJump(CompletionType jumpID, int targetLexicalScopeIndex, Label& targetLabel) + : jumpID(jumpID) + , targetLexicalScopeIndex(targetLexicalScopeIndex) + , targetLabel(targetLabel) + { } + + CompletionType jumpID; + int targetLexicalScopeIndex; + Ref