summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/interpreter/CallFrame.h
diff options
context:
space:
mode:
Diffstat (limited to 'JavaScriptCore/interpreter/CallFrame.h')
-rw-r--r--JavaScriptCore/interpreter/CallFrame.h58
1 files changed, 35 insertions, 23 deletions
diff --git a/JavaScriptCore/interpreter/CallFrame.h b/JavaScriptCore/interpreter/CallFrame.h
index e3ea689..2797ef3 100644
--- a/JavaScriptCore/interpreter/CallFrame.h
+++ b/JavaScriptCore/interpreter/CallFrame.h
@@ -24,6 +24,7 @@
#define CallFrame_h
#include "JSGlobalData.h"
+#include "MacroAssemblerCodeRef.h"
#include "RegisterFile.h"
#include "ScopeChain.h"
@@ -37,16 +38,13 @@ namespace JSC {
// Passed as the first argument to most functions.
class ExecState : private Register {
public:
- JSFunction* callee() const { return this[RegisterFile::Callee].function(); }
+ JSObject* callee() const { return this[RegisterFile::Callee].function(); }
CodeBlock* codeBlock() const { return this[RegisterFile::CodeBlock].Register::codeBlock(); }
ScopeChainNode* scopeChain() const
{
ASSERT(this[RegisterFile::ScopeChain].Register::scopeChain());
return this[RegisterFile::ScopeChain].Register::scopeChain();
}
- int argumentCount() const { return this[RegisterFile::ArgumentCount].i(); }
-
- JSValue thisValue();
// Global object in which execution began.
JSGlobalObject* dynamicGlobalObject();
@@ -65,9 +63,6 @@ namespace JSC {
return scopeChain()->globalThis;
}
- // FIXME: Elsewhere, we use JSGlobalData* rather than JSGlobalData&.
- // We should make this more uniform and either use a reference everywhere
- // or a pointer everywhere.
JSGlobalData& globalData() const
{
ASSERT(scopeChain()->globalData);
@@ -79,10 +74,8 @@ namespace JSC {
// pointer, so these are inefficient, and should be used sparingly in new code.
// But they're used in many places in legacy code, so they're not going away any time soon.
- void setException(JSValue exception) { globalData().exception = exception; }
void clearException() { globalData().exception = JSValue(); }
JSValue exception() const { return globalData().exception; }
- JSValue* exceptionSlot() { return &globalData().exception; }
bool hadException() const { return globalData().exception; }
const CommonIdentifiers& propertyNames() const { return *globalData().propertyNames; }
@@ -107,45 +100,64 @@ namespace JSC {
CallFrame& operator=(const Register& r) { *static_cast<Register*>(this) = r; return *this; }
CallFrame* callerFrame() const { return this[RegisterFile::CallerFrame].callFrame(); }
- Arguments* optionalCalleeArguments() const { return this[RegisterFile::OptionalCalleeArguments].arguments(); }
- Instruction* returnPC() const { return this[RegisterFile::ReturnPC].vPC(); }
+#if ENABLE(JIT)
+ ReturnAddressPtr returnPC() const { return ReturnAddressPtr(this[RegisterFile::ReturnPC].vPC()); }
+#endif
+#if ENABLE(INTERPRETER)
+ Instruction* returnVPC() const { return this[RegisterFile::ReturnPC].vPC(); }
+#endif
- void setCalleeArguments(JSValue arguments) { static_cast<Register*>(this)[RegisterFile::OptionalCalleeArguments] = arguments; }
void setCallerFrame(CallFrame* callerFrame) { static_cast<Register*>(this)[RegisterFile::CallerFrame] = callerFrame; }
void setScopeChain(ScopeChainNode* scopeChain) { static_cast<Register*>(this)[RegisterFile::ScopeChain] = scopeChain; }
ALWAYS_INLINE void init(CodeBlock* codeBlock, Instruction* vPC, ScopeChainNode* scopeChain,
- CallFrame* callerFrame, int returnValueRegister, int argc, JSFunction* function)
+ CallFrame* callerFrame, int argc, JSObject* callee)
{
ASSERT(callerFrame); // Use noCaller() rather than 0 for the outer host call frame caller.
+ ASSERT(callerFrame == noCaller() || callerFrame->removeHostCallFrameFlag()->registerFile()->end() >= this);
setCodeBlock(codeBlock);
setScopeChain(scopeChain);
setCallerFrame(callerFrame);
- static_cast<Register*>(this)[RegisterFile::ReturnPC] = vPC; // This is either an Instruction* or a pointer into JIT generated code stored as an Instruction*.
- static_cast<Register*>(this)[RegisterFile::ReturnValueRegister] = Register::withInt(returnValueRegister);
- setArgumentCount(argc); // original argument count (for the sake of the "arguments" object)
- setCallee(function);
- setCalleeArguments(JSValue());
+ setReturnPC(vPC); // This is either an Instruction* or a pointer into JIT generated code stored as an Instruction*.
+ setArgumentCountIncludingThis(argc); // original argument count (for the sake of the "arguments" object)
+ setCallee(callee);
}
// Read a register from the codeframe (or constant from the CodeBlock).
inline Register& r(int);
+ // Read a register for a non-constant
+ inline Register& uncheckedR(int);
+
+ // Access to arguments.
+ int hostThisRegister() { return -RegisterFile::CallFrameHeaderSize - argumentCountIncludingThis(); }
+ JSValue hostThisValue() { return this[hostThisRegister()].jsValue(); }
+ size_t argumentCount() const { return argumentCountIncludingThis() - 1; }
+ size_t argumentCountIncludingThis() const { return this[RegisterFile::ArgumentCount].i(); }
+ JSValue argument(int argumentNumber)
+ {
+ int argumentIndex = -RegisterFile::CallFrameHeaderSize - this[RegisterFile::ArgumentCount].i() + argumentNumber + 1;
+ if (argumentIndex >= -RegisterFile::CallFrameHeaderSize)
+ return jsUndefined();
+ return this[argumentIndex].jsValue();
+ }
static CallFrame* noCaller() { return reinterpret_cast<CallFrame*>(HostCallFrameFlag); }
- int returnValueRegister() const { return this[RegisterFile::ReturnValueRegister].i(); }
bool hasHostCallFrameFlag() const { return reinterpret_cast<intptr_t>(this) & HostCallFrameFlag; }
CallFrame* addHostCallFrameFlag() const { return reinterpret_cast<CallFrame*>(reinterpret_cast<intptr_t>(this) | HostCallFrameFlag); }
CallFrame* removeHostCallFrameFlag() { return reinterpret_cast<CallFrame*>(reinterpret_cast<intptr_t>(this) & ~HostCallFrameFlag); }
- private:
- void setArgumentCount(int count) { static_cast<Register*>(this)[RegisterFile::ArgumentCount] = Register::withInt(count); }
- void setCallee(JSFunction* callee) { static_cast<Register*>(this)[RegisterFile::Callee] = callee; }
+ void setArgumentCountIncludingThis(int count) { static_cast<Register*>(this)[RegisterFile::ArgumentCount] = Register::withInt(count); }
+ void setCallee(JSObject* callee) { static_cast<Register*>(this)[RegisterFile::Callee] = Register::withCallee(callee); }
void setCodeBlock(CodeBlock* codeBlock) { static_cast<Register*>(this)[RegisterFile::CodeBlock] = codeBlock; }
+ void setReturnPC(void* value) { static_cast<Register*>(this)[RegisterFile::ReturnPC] = (Instruction*)value; }
+ private:
static const intptr_t HostCallFrameFlag = 1;
-
+#ifndef NDEBUG
+ RegisterFile* registerFile();
+#endif
ExecState();
~ExecState();
};