summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2013-09-13 12:51:20 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-19 20:50:05 +0200
commitd441d6f39bb846989d95bcf5caf387b42414718d (patch)
treee367e64a75991c554930278175d403c072de6bb8 /Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
parent0060b2994c07842f4c59de64b5e3e430525c4b90 (diff)
downloadqtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit. Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h')
-rw-r--r--Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h165
1 files changed, 89 insertions, 76 deletions
diff --git a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
index 23937d773..634968313 100644
--- a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
+++ b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2012, 2013 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,16 +27,18 @@
#define UnlinkedCodeBlock_h
#include "BytecodeConventions.h"
+#include "CodeCache.h"
#include "CodeSpecializationKind.h"
#include "CodeType.h"
#include "ExpressionRangeInfo.h"
#include "Identifier.h"
#include "JSCell.h"
+#include "JSString.h"
#include "LineInfo.h"
-#include "Nodes.h"
+#include "ParserModes.h"
#include "RegExp.h"
#include "SpecialPointer.h"
-#include "Weak.h"
+#include "SymbolTable.h"
#include <wtf/RefCountedArray.h>
#include <wtf/Vector.h>
@@ -47,6 +49,7 @@ class Debugger;
class FunctionBodyNode;
class FunctionExecutable;
class FunctionParameters;
+class JSScope;
struct ParserError;
class ScriptExecutable;
class SourceCode;
@@ -58,6 +61,7 @@ class UnlinkedFunctionCodeBlock;
typedef unsigned UnlinkedValueProfile;
typedef unsigned UnlinkedArrayProfile;
typedef unsigned UnlinkedArrayAllocationProfile;
+typedef unsigned UnlinkedObjectAllocationProfile;
typedef unsigned UnlinkedLLIntCallLinkInfo;
struct ExecutableInfo {
@@ -78,10 +82,10 @@ class UnlinkedFunctionExecutable : public JSCell {
public:
friend class CodeCache;
typedef JSCell Base;
- static UnlinkedFunctionExecutable* create(JSGlobalData* globalData, const SourceCode& source, FunctionBodyNode* node)
+ static UnlinkedFunctionExecutable* create(VM* vm, const SourceCode& source, FunctionBodyNode* node)
{
- UnlinkedFunctionExecutable* instance = new (NotNull, allocateCell<UnlinkedFunctionExecutable>(globalData->heap)) UnlinkedFunctionExecutable(globalData, globalData->unlinkedFunctionExecutableStructure.get(), source, node);
- instance->finishCreation(*globalData);
+ UnlinkedFunctionExecutable* instance = new (NotNull, allocateCell<UnlinkedFunctionExecutable>(vm->heap)) UnlinkedFunctionExecutable(vm, vm->unlinkedFunctionExecutableStructure.get(), source, node);
+ instance->finishCreation(*vm);
return instance;
}
@@ -92,22 +96,24 @@ public:
{
return (kind == CodeForCall) ? m_symbolTableForCall.get() : m_symbolTableForConstruct.get();
}
- size_t parameterCount() const { return m_parameters->size(); }
+ size_t parameterCount() const;
bool isInStrictContext() const { return m_isInStrictContext; }
FunctionNameIsInScopeToggle functionNameIsInScopeToggle() const { return m_functionNameIsInScopeToggle; }
unsigned firstLineOffset() const { return m_firstLineOffset; }
unsigned lineCount() const { return m_lineCount; }
+ unsigned functionStartOffset() const { return m_functionStartOffset; }
+ unsigned functionStartColumn() const { return m_functionStartColumn; }
unsigned startOffset() const { return m_startOffset; }
unsigned sourceLength() { return m_sourceLength; }
String paramString() const;
- UnlinkedFunctionCodeBlock* codeBlockFor(JSGlobalData&, const SourceCode&, CodeSpecializationKind, DebuggerMode, ProfilerMode, ParserError&);
+ UnlinkedFunctionCodeBlock* codeBlockFor(VM&, JSScope*, const SourceCode&, CodeSpecializationKind, DebuggerMode, ProfilerMode, ParserError&);
static UnlinkedFunctionExecutable* fromGlobalCode(const Identifier&, ExecState*, Debugger*, const SourceCode&, JSObject** exception);
- FunctionExecutable* link(JSGlobalData&, const SourceCode&, size_t lineOffset, size_t sourceOffset);
+ FunctionExecutable* link(VM&, const SourceCode&, size_t lineOffset, size_t sourceOffset);
void clearCodeForRecompilation()
{
@@ -136,9 +142,9 @@ public:
static void destroy(JSCell*);
private:
- UnlinkedFunctionExecutable(JSGlobalData*, Structure*, const SourceCode&, FunctionBodyNode*);
- Weak<UnlinkedFunctionCodeBlock> m_codeBlockForCall;
- Weak<UnlinkedFunctionCodeBlock> m_codeBlockForConstruct;
+ UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&, FunctionBodyNode*);
+ WriteBarrier<UnlinkedFunctionCodeBlock> m_codeBlockForCall;
+ WriteBarrier<UnlinkedFunctionCodeBlock> m_codeBlockForConstruct;
unsigned m_numCapturedVariables : 29;
bool m_forceUsesArguments : 1;
@@ -153,6 +159,8 @@ private:
RefPtr<FunctionParameters> m_parameters;
unsigned m_firstLineOffset;
unsigned m_lineCount;
+ unsigned m_functionStartOffset;
+ unsigned m_functionStartColumn;
unsigned m_startOffset;
unsigned m_sourceLength;
@@ -161,18 +169,18 @@ private:
FunctionNameIsInScopeToggle m_functionNameIsInScopeToggle;
protected:
- void finishCreation(JSGlobalData& globalData)
+ void finishCreation(VM& vm)
{
- Base::finishCreation(globalData);
- m_nameValue.set(globalData, this, jsString(&globalData, name().string()));
+ Base::finishCreation(vm);
+ m_nameValue.set(vm, this, jsString(&vm, name().string()));
}
static void visitChildren(JSCell*, SlotVisitor&);
public:
- static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue proto)
+ static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue proto)
{
- return Structure::create(globalData, globalObject, proto, TypeInfo(UnlinkedFunctionExecutableType, StructureFlags), &s_info);
+ return Structure::create(vm, globalObject, proto, TypeInfo(UnlinkedFunctionExecutableType, StructureFlags), &s_info);
}
static const unsigned StructureFlags = OverridesVisitChildren | JSCell::StructureFlags;
@@ -239,19 +247,8 @@ public:
bool needsFullScopeChain() const { return m_needsFullScopeChain; }
void setNeedsFullScopeChain(bool needsFullScopeChain) { m_needsFullScopeChain = needsFullScopeChain; }
- void addExpressionInfo(const ExpressionRangeInfo& expressionInfo)
- {
- m_expressionInfo.append(expressionInfo);
- }
-
- void addLineInfo(unsigned bytecodeOffset, int lineNo)
- {
- Vector<LineInfo>& lineInfo = m_lineInfo;
- if (!lineInfo.size() || lineInfo.last().lineNumber != lineNo) {
- LineInfo info = { bytecodeOffset, lineNo };
- lineInfo.append(info);
- }
- }
+ void addExpressionInfo(unsigned instructionOffset, int divot,
+ int startOffset, int endOffset, unsigned line, unsigned column);
bool hasExpressionInfo() { return m_expressionInfo.size(); }
@@ -263,6 +260,11 @@ public:
bool usesArguments() const { return m_argumentsRegister != -1; }
int argumentsRegister() const { return m_argumentsRegister; }
+
+ bool usesGlobalObject() const { return m_globalObjectRegister != -1; }
+ void setGlobalObjectRegister(int globalObjectRegister) { m_globalObjectRegister = globalObjectRegister; }
+ int globalObjectRegister() const { return m_globalObjectRegister; }
+
// Parameter information
void setNumParameters(int newValue) { m_numParameters = newValue; }
void addParameter() { m_numParameters++; }
@@ -272,7 +274,7 @@ public:
{
createRareDataIfNecessary();
unsigned size = m_rareData->m_regexps.size();
- m_rareData->m_regexps.append(WriteBarrier<RegExp>(*m_globalData, this, r));
+ m_rareData->m_regexps.append(WriteBarrier<RegExp>(*m_vm, this, r));
return size;
}
unsigned numberOfRegExps() const
@@ -295,7 +297,7 @@ public:
{
unsigned result = m_constantRegisters.size();
m_constantRegisters.append(WriteBarrier<Unknown>());
- m_constantRegisters.last().set(*m_globalData, this, v);
+ m_constantRegisters.last().set(*m_vm, this, v);
return result;
}
unsigned addOrFindConstant(JSValue);
@@ -320,7 +322,6 @@ public:
m_constantRegisters.shrinkToFit();
m_functionDecls.shrinkToFit();
m_functionExprs.shrinkToFit();
- m_lineInfo.shrinkToFit();
m_propertyAccessInstructions.shrinkToFit();
m_expressionInfo.shrinkToFit();
@@ -334,6 +335,7 @@ public:
m_rareData->m_immediateSwitchJumpTables.shrinkToFit();
m_rareData->m_characterSwitchJumpTables.shrinkToFit();
m_rareData->m_stringSwitchJumpTables.shrinkToFit();
+ m_rareData->m_expressionInfoFatPositions.shrinkToFit();
}
}
@@ -363,7 +365,7 @@ public:
{
unsigned size = m_functionDecls.size();
m_functionDecls.append(WriteBarrier<UnlinkedFunctionExecutable>());
- m_functionDecls.last().set(*m_globalData, this, n);
+ m_functionDecls.last().set(*m_vm, this, n);
return size;
}
UnlinkedFunctionExecutable* functionDecl(int index) { return m_functionDecls[index].get(); }
@@ -372,7 +374,7 @@ public:
{
unsigned size = m_functionExprs.size();
m_functionExprs.append(WriteBarrier<UnlinkedFunctionExecutable>());
- m_functionExprs.last().set(*m_globalData, this, n);
+ m_functionExprs.last().set(*m_vm, this, n);
return size;
}
UnlinkedFunctionExecutable* functionExpr(int index) { return m_functionExprs[index].get(); }
@@ -385,7 +387,7 @@ public:
SharedSymbolTable* symbolTable() const { return m_symbolTable.get(); }
- JSGlobalData* globalData() const { return m_globalData; }
+ VM* vm() const { return m_vm; }
unsigned addResolve() { return m_resolveOperationCount++; }
unsigned numberOfResolveOperations() const { return m_resolveOperationCount; }
@@ -396,6 +398,8 @@ public:
unsigned numberOfArrayProfiles() { return m_arrayProfileCount; }
UnlinkedArrayAllocationProfile addArrayAllocationProfile() { return m_arrayAllocationProfileCount++; }
unsigned numberOfArrayAllocationProfiles() { return m_arrayAllocationProfileCount; }
+ UnlinkedObjectAllocationProfile addObjectAllocationProfile() { return m_objectAllocationProfileCount++; }
+ unsigned numberOfObjectAllocationProfiles() { return m_objectAllocationProfileCount; }
UnlinkedValueProfile addValueProfile() { return m_valueProfileCount++; }
unsigned numberOfValueProfiles() { return m_valueProfileCount; }
@@ -443,7 +447,8 @@ public:
int lineNumberForBytecodeOffset(unsigned bytecodeOffset);
- void expressionRangeForBytecodeOffset(unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset);
+ void expressionRangeForBytecodeOffset(unsigned bytecodeOffset, int& divot,
+ int& startOffset, int& endOffset, unsigned& line, unsigned& column);
void recordParse(CodeFeatures features, bool hasCapturedVariables, unsigned firstLine, unsigned lineCount)
{
@@ -458,16 +463,26 @@ public:
unsigned firstLine() const { return m_firstLine; }
unsigned lineCount() const { return m_lineCount; }
+ PassRefPtr<CodeCache> codeCacheForEval()
+ {
+ if (m_codeType == GlobalCode)
+ return m_vm->codeCache();
+ createRareDataIfNecessary();
+ if (!m_rareData->m_evalCodeCache)
+ m_rareData->m_evalCodeCache = CodeCache::create(CodeCache::NonGlobalCodeCache);
+ return m_rareData->m_evalCodeCache.get();
+ }
+
protected:
- UnlinkedCodeBlock(JSGlobalData*, Structure*, CodeType, const ExecutableInfo&);
+ UnlinkedCodeBlock(VM*, Structure*, CodeType, const ExecutableInfo&);
~UnlinkedCodeBlock();
- void finishCreation(JSGlobalData& globalData)
+ void finishCreation(VM& vm)
{
- Base::finishCreation(globalData);
+ Base::finishCreation(vm);
if (codeType() == GlobalCode)
return;
- m_symbolTable.set(globalData, this, SharedSymbolTable::create(globalData));
+ m_symbolTable.set(vm, this, SharedSymbolTable::create(vm));
}
private:
@@ -481,11 +496,12 @@ private:
RefCountedArray<UnlinkedInstruction> m_unlinkedInstructions;
int m_numParameters;
- JSGlobalData* m_globalData;
+ VM* m_vm;
int m_thisRegister;
int m_argumentsRegister;
int m_activationRegister;
+ int m_globalObjectRegister;
bool m_needsFullScopeChain : 1;
bool m_usesEval : 1;
@@ -510,8 +526,6 @@ private:
WriteBarrier<SharedSymbolTable> m_symbolTable;
- Vector<LineInfo> m_lineInfo;
-
Vector<unsigned> m_propertyAccessInstructions;
#if ENABLE(BYTECODE_COMMENTS)
@@ -523,6 +537,7 @@ private:
unsigned m_putToBaseOperationCount;
unsigned m_arrayProfileCount;
unsigned m_arrayAllocationProfileCount;
+ unsigned m_objectAllocationProfileCount;
unsigned m_valueProfileCount;
unsigned m_llintCallLinkInfoCount;
@@ -542,8 +557,9 @@ public:
Vector<UnlinkedSimpleJumpTable> m_immediateSwitchJumpTables;
Vector<UnlinkedSimpleJumpTable> m_characterSwitchJumpTables;
Vector<UnlinkedStringJumpTable> m_stringSwitchJumpTables;
+ RefPtr<CodeCache> m_evalCodeCache;
- // Expression info - present if debugging.
+ Vector<ExpressionRangeInfo::FatPosition> m_expressionInfoFatPositions;
};
private:
@@ -564,8 +580,8 @@ public:
typedef UnlinkedCodeBlock Base;
protected:
- UnlinkedGlobalCodeBlock(JSGlobalData* globalData, Structure* structure, CodeType codeType, const ExecutableInfo& info)
- : Base(globalData, structure, codeType, info)
+ UnlinkedGlobalCodeBlock(VM* vm, Structure* structure, CodeType codeType, const ExecutableInfo& info)
+ : Base(vm, structure, codeType, info)
{
}
@@ -577,10 +593,10 @@ protected:
class UnlinkedProgramCodeBlock : public UnlinkedGlobalCodeBlock {
private:
friend class CodeCache;
- static UnlinkedProgramCodeBlock* create(JSGlobalData* globalData, const ExecutableInfo& info)
+ static UnlinkedProgramCodeBlock* create(VM* vm, const ExecutableInfo& info)
{
- UnlinkedProgramCodeBlock* instance = new (NotNull, allocateCell<UnlinkedProgramCodeBlock>(globalData->heap)) UnlinkedProgramCodeBlock(globalData, globalData->unlinkedProgramCodeBlockStructure.get(), info);
- instance->finishCreation(*globalData);
+ UnlinkedProgramCodeBlock* instance = new (NotNull, allocateCell<UnlinkedProgramCodeBlock>(vm->heap)) UnlinkedProgramCodeBlock(vm, vm->unlinkedProgramCodeBlockStructure.get(), info);
+ instance->finishCreation(*vm);
return instance;
}
@@ -588,9 +604,9 @@ public:
typedef UnlinkedGlobalCodeBlock Base;
static void destroy(JSCell*);
- void addFunctionDeclaration(JSGlobalData& globalData, const Identifier& name, UnlinkedFunctionExecutable* functionExecutable)
+ void addFunctionDeclaration(VM& vm, const Identifier& name, UnlinkedFunctionExecutable* functionExecutable)
{
- m_functionDeclarations.append(std::make_pair(name, WriteBarrier<UnlinkedFunctionExecutable>(globalData, this, functionExecutable)));
+ m_functionDeclarations.append(std::make_pair(name, WriteBarrier<UnlinkedFunctionExecutable>(vm, this, functionExecutable)));
}
void addVariableDeclaration(const Identifier& name, bool isConstant)
@@ -607,8 +623,8 @@ public:
static void visitChildren(JSCell*, SlotVisitor&);
private:
- UnlinkedProgramCodeBlock(JSGlobalData* globalData, Structure* structure, const ExecutableInfo& info)
- : Base(globalData, structure, GlobalCode, info)
+ UnlinkedProgramCodeBlock(VM* vm, Structure* structure, const ExecutableInfo& info)
+ : Base(vm, structure, GlobalCode, info)
{
}
@@ -616,9 +632,9 @@ private:
FunctionDeclations m_functionDeclarations;
public:
- static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue proto)
+ static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue proto)
{
- return Structure::create(globalData, globalObject, proto, TypeInfo(UnlinkedProgramCodeBlockType, StructureFlags), &s_info);
+ return Structure::create(vm, globalObject, proto, TypeInfo(UnlinkedProgramCodeBlockType, StructureFlags), &s_info);
}
static const unsigned StructureFlags = OverridesVisitChildren | Base::StructureFlags;
@@ -630,10 +646,10 @@ class UnlinkedEvalCodeBlock : public UnlinkedGlobalCodeBlock {
private:
friend class CodeCache;
- static UnlinkedEvalCodeBlock* create(JSGlobalData* globalData, const ExecutableInfo& info)
+ static UnlinkedEvalCodeBlock* create(VM* vm, const ExecutableInfo& info)
{
- UnlinkedEvalCodeBlock* instance = new (NotNull, allocateCell<UnlinkedEvalCodeBlock>(globalData->heap)) UnlinkedEvalCodeBlock(globalData, globalData->unlinkedEvalCodeBlockStructure.get(), info);
- instance->finishCreation(*globalData);
+ UnlinkedEvalCodeBlock* instance = new (NotNull, allocateCell<UnlinkedEvalCodeBlock>(vm->heap)) UnlinkedEvalCodeBlock(vm, vm->unlinkedEvalCodeBlockStructure.get(), info);
+ instance->finishCreation(*vm);
return instance;
}
@@ -643,24 +659,24 @@ public:
const Identifier& variable(unsigned index) { return m_variables[index]; }
unsigned numVariables() { return m_variables.size(); }
- void adoptVariables(Vector<Identifier>& variables)
+ void adoptVariables(Vector<Identifier, 0, UnsafeVectorOverflow>& variables)
{
ASSERT(m_variables.isEmpty());
m_variables.swap(variables);
}
private:
- UnlinkedEvalCodeBlock(JSGlobalData* globalData, Structure* structure, const ExecutableInfo& info)
- : Base(globalData, structure, EvalCode, info)
+ UnlinkedEvalCodeBlock(VM* vm, Structure* structure, const ExecutableInfo& info)
+ : Base(vm, structure, EvalCode, info)
{
}
- Vector<Identifier> m_variables;
+ Vector<Identifier, 0, UnsafeVectorOverflow> m_variables;
public:
- static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue proto)
+ static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue proto)
{
- return Structure::create(globalData, globalObject, proto, TypeInfo(UnlinkedEvalCodeBlockType, StructureFlags), &s_info);
+ return Structure::create(vm, globalObject, proto, TypeInfo(UnlinkedEvalCodeBlockType, StructureFlags), &s_info);
}
static const unsigned StructureFlags = OverridesVisitChildren | Base::StructureFlags;
@@ -669,30 +685,27 @@ public:
};
class UnlinkedFunctionCodeBlock : public UnlinkedCodeBlock {
-private:
- friend class CodeCache;
-
- static UnlinkedFunctionCodeBlock* create(JSGlobalData* globalData, CodeType codeType, const ExecutableInfo& info)
+public:
+ static UnlinkedFunctionCodeBlock* create(VM* vm, CodeType codeType, const ExecutableInfo& info)
{
- UnlinkedFunctionCodeBlock* instance = new (NotNull, allocateCell<UnlinkedFunctionCodeBlock>(globalData->heap)) UnlinkedFunctionCodeBlock(globalData, globalData->unlinkedFunctionCodeBlockStructure.get(), codeType, info);
- instance->finishCreation(*globalData);
+ UnlinkedFunctionCodeBlock* instance = new (NotNull, allocateCell<UnlinkedFunctionCodeBlock>(vm->heap)) UnlinkedFunctionCodeBlock(vm, vm->unlinkedFunctionCodeBlockStructure.get(), codeType, info);
+ instance->finishCreation(*vm);
return instance;
}
-public:
typedef UnlinkedCodeBlock Base;
static void destroy(JSCell*);
private:
- UnlinkedFunctionCodeBlock(JSGlobalData* globalData, Structure* structure, CodeType codeType, const ExecutableInfo& info)
- : Base(globalData, structure, codeType, info)
+ UnlinkedFunctionCodeBlock(VM* vm, Structure* structure, CodeType codeType, const ExecutableInfo& info)
+ : Base(vm, structure, codeType, info)
{
}
public:
- static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue proto)
+ static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue proto)
{
- return Structure::create(globalData, globalObject, proto, TypeInfo(UnlinkedFunctionCodeBlockType, StructureFlags), &s_info);
+ return Structure::create(vm, globalObject, proto, TypeInfo(UnlinkedFunctionCodeBlockType, StructureFlags), &s_info);
}
static const unsigned StructureFlags = OverridesVisitChildren | Base::StructureFlags;