From 2bde8e466a4451c7319e3a072d118917957d6554 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Wed, 25 May 2011 19:08:45 +0100 Subject: Merge WebKit at r82507: Initial merge by git Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e --- Source/JavaScriptCore/interpreter/CachedCall.h | 2 +- Source/JavaScriptCore/interpreter/CallFrame.h | 2 +- Source/JavaScriptCore/interpreter/Interpreter.cpp | 55 +++++++++--------- Source/JavaScriptCore/interpreter/Register.h | 66 ++++------------------ Source/JavaScriptCore/interpreter/RegisterFile.cpp | 11 ++++ Source/JavaScriptCore/interpreter/RegisterFile.h | 8 ++- 6 files changed, 59 insertions(+), 85 deletions(-) (limited to 'Source/JavaScriptCore/interpreter') diff --git a/Source/JavaScriptCore/interpreter/CachedCall.h b/Source/JavaScriptCore/interpreter/CachedCall.h index 05e9056..04f2210 100644 --- a/Source/JavaScriptCore/interpreter/CachedCall.h +++ b/Source/JavaScriptCore/interpreter/CachedCall.h @@ -38,7 +38,7 @@ namespace JSC { CachedCall(CallFrame* callFrame, JSFunction* function, int argCount) : m_valid(false) , m_interpreter(callFrame->interpreter()) - , m_globalObjectScope(callFrame, function->scope()->globalObject.get()) + , m_globalObjectScope(callFrame->globalData(), function->scope()->globalObject.get()) { ASSERT(!function->isHostFunction()); m_closure = m_interpreter->prepareForRepeatCall(function->jsExecutable(), callFrame, function, argCount, function->scope()); diff --git a/Source/JavaScriptCore/interpreter/CallFrame.h b/Source/JavaScriptCore/interpreter/CallFrame.h index e73e13a..28832e0 100644 --- a/Source/JavaScriptCore/interpreter/CallFrame.h +++ b/Source/JavaScriptCore/interpreter/CallFrame.h @@ -65,7 +65,7 @@ namespace JSC { // But they're used in many places in legacy code, so they're not going away any time soon. void clearException() { globalData().exception = JSValue(); } - JSValue exception() const { return globalData().exception.get(); } + JSValue exception() const { return globalData().exception; } bool hadException() const { return globalData().exception; } const CommonIdentifiers& propertyNames() const { return *globalData().propertyNames; } diff --git a/Source/JavaScriptCore/interpreter/Interpreter.cpp b/Source/JavaScriptCore/interpreter/Interpreter.cpp index b9a9c40..6021279 100644 --- a/Source/JavaScriptCore/interpreter/Interpreter.cpp +++ b/Source/JavaScriptCore/interpreter/Interpreter.cpp @@ -106,7 +106,7 @@ NEVER_INLINE bool Interpreter::resolve(CallFrame* callFrame, Instruction* vPC, J PropertySlot slot(o); if (o->getPropertySlot(callFrame, ident, slot)) { JSValue result = slot.getValue(callFrame, ident); - exceptionValue = callFrame->globalData().exception.get(); + exceptionValue = callFrame->globalData().exception; if (exceptionValue) return false; callFrame->uncheckedR(dst) = JSValue(result); @@ -145,7 +145,7 @@ NEVER_INLINE bool Interpreter::resolveSkip(CallFrame* callFrame, Instruction* vP PropertySlot slot(o); if (o->getPropertySlot(callFrame, ident, slot)) { JSValue result = slot.getValue(callFrame, ident); - exceptionValue = callFrame->globalData().exception.get(); + exceptionValue = callFrame->globalData().exception; if (exceptionValue) return false; ASSERT(result); @@ -186,7 +186,7 @@ NEVER_INLINE bool Interpreter::resolveGlobal(CallFrame* callFrame, Instruction* return true; } - exceptionValue = callFrame->globalData().exception.get(); + exceptionValue = callFrame->globalData().exception; if (exceptionValue) return false; callFrame->uncheckedR(dst) = JSValue(result); @@ -226,7 +226,7 @@ NEVER_INLINE bool Interpreter::resolveGlobalDynamic(CallFrame* callFrame, Instru PropertySlot slot(o); if (o->getPropertySlot(callFrame, ident, slot)) { JSValue result = slot.getValue(callFrame, ident); - exceptionValue = callFrame->globalData().exception.get(); + exceptionValue = callFrame->globalData().exception; if (exceptionValue) return false; ASSERT(result); @@ -265,7 +265,7 @@ NEVER_INLINE bool Interpreter::resolveGlobalDynamic(CallFrame* callFrame, Instru return true; } - exceptionValue = callFrame->globalData().exception.get(); + exceptionValue = callFrame->globalData().exception; if (exceptionValue) return false; ASSERT(result); @@ -313,7 +313,7 @@ NEVER_INLINE bool Interpreter::resolveBaseAndProperty(CallFrame* callFrame, Inst PropertySlot slot(base); if (base->getPropertySlot(callFrame, ident, slot)) { JSValue result = slot.getValue(callFrame, ident); - exceptionValue = callFrame->globalData().exception.get(); + exceptionValue = callFrame->globalData().exception; if (exceptionValue) return false; callFrame->uncheckedR(propDst) = JSValue(result); @@ -409,13 +409,13 @@ NEVER_INLINE JSValue Interpreter::callEval(CallFrame* callFrame, RegisterFile* r ScopeChainNode* scopeChain = callFrame->scopeChain(); JSValue exceptionValue; - RefPtr eval = codeBlock->evalCodeCache().get(callFrame, codeBlock->isStrictMode(), programSource, scopeChain, exceptionValue); + EvalExecutable* eval = codeBlock->evalCodeCache().get(callFrame, codeBlock->ownerExecutable(), codeBlock->isStrictMode(), programSource, scopeChain, exceptionValue); ASSERT(!eval == exceptionValue); if (UNLIKELY(!eval)) return throwError(callFrame, exceptionValue); - return callFrame->globalData().interpreter->execute(eval.get(), callFrame, callFrame->uncheckedR(codeBlock->thisRegister()).jsValue().toThisObject(callFrame), callFrame->registers() - registerFile->start() + registerOffset, scopeChain); + return callFrame->globalData().interpreter->execute(eval, callFrame, callFrame->uncheckedR(codeBlock->thisRegister()).jsValue().toThisObject(callFrame), callFrame->registers() - registerFile->start() + registerOffset, scopeChain); } Interpreter::Interpreter(JSGlobalData& globalData) @@ -738,6 +738,8 @@ JSValue Interpreter::execute(ProgramExecutable* program, CallFrame* callFrame, S if (m_reentryDepth >= MaxSmallThreadReentryDepth && m_reentryDepth >= callFrame->globalData().maxReentryDepth) return checkedReturn(throwStackOverflowError(callFrame)); + DynamicGlobalObjectScope globalObjectScope(*scopeChain->globalData, scopeChain->globalObject.get()); + JSObject* error = program->compile(callFrame, scopeChain); if (error) return checkedReturn(throwError(callFrame, error)); @@ -757,8 +759,6 @@ JSValue Interpreter::execute(ProgramExecutable* program, CallFrame* callFrame, S newCallFrame->init(codeBlock, 0, scopeChain, CallFrame::noCaller(), codeBlock->m_numParameters, 0); newCallFrame->uncheckedR(newCallFrame->hostThisRegister()) = JSValue(thisObj); - DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject.get()); - Profiler** profiler = Profiler::enabledProfilerReference(); if (*profiler) (*profiler)->willExecute(callFrame, program->sourceURL(), program->lineNo()); @@ -813,6 +813,8 @@ JSValue Interpreter::executeCall(CallFrame* callFrame, JSObject* function, CallT if (callType == CallTypeJS) { ScopeChainNode* callDataScopeChain = callData.js.scopeChain; + DynamicGlobalObjectScope globalObjectScope(*callDataScopeChain->globalData, callDataScopeChain->globalObject.get()); + JSObject* compileError = callData.js.functionExecutable->compileForCall(callFrame, callDataScopeChain); if (UNLIKELY(!!compileError)) { m_registerFile.shrink(oldEnd); @@ -828,8 +830,6 @@ JSValue Interpreter::executeCall(CallFrame* callFrame, JSObject* function, CallT newCallFrame->init(newCodeBlock, 0, callDataScopeChain, callFrame->addHostCallFrameFlag(), argCount, function); - DynamicGlobalObjectScope globalObjectScope(newCallFrame, callDataScopeChain->globalObject.get()); - Profiler** profiler = Profiler::enabledProfilerReference(); if (*profiler) (*profiler)->willExecute(callFrame, function); @@ -860,7 +860,7 @@ JSValue Interpreter::executeCall(CallFrame* callFrame, JSObject* function, CallT newCallFrame = CallFrame::create(newCallFrame->registers() + registerOffset); newCallFrame->init(0, 0, scopeChain, callFrame->addHostCallFrameFlag(), argCount, function); - DynamicGlobalObjectScope globalObjectScope(newCallFrame, scopeChain->globalObject.get()); + DynamicGlobalObjectScope globalObjectScope(*scopeChain->globalData, scopeChain->globalObject.get()); Profiler** profiler = Profiler::enabledProfilerReference(); if (*profiler) @@ -902,6 +902,8 @@ JSObject* Interpreter::executeConstruct(CallFrame* callFrame, JSObject* construc if (constructType == ConstructTypeJS) { ScopeChainNode* constructDataScopeChain = constructData.js.scopeChain; + DynamicGlobalObjectScope globalObjectScope(*constructDataScopeChain->globalData, constructDataScopeChain->globalObject.get()); + JSObject* compileError = constructData.js.functionExecutable->compileForConstruct(callFrame, constructDataScopeChain); if (UNLIKELY(!!compileError)) { m_registerFile.shrink(oldEnd); @@ -917,8 +919,6 @@ JSObject* Interpreter::executeConstruct(CallFrame* callFrame, JSObject* construc newCallFrame->init(newCodeBlock, 0, constructDataScopeChain, callFrame->addHostCallFrameFlag(), argCount, constructor); - DynamicGlobalObjectScope globalObjectScope(newCallFrame, constructDataScopeChain->globalObject.get()); - Profiler** profiler = Profiler::enabledProfilerReference(); if (*profiler) (*profiler)->willExecute(callFrame, constructor); @@ -952,7 +952,7 @@ JSObject* Interpreter::executeConstruct(CallFrame* callFrame, JSObject* construc newCallFrame = CallFrame::create(newCallFrame->registers() + registerOffset); newCallFrame->init(0, 0, scopeChain, callFrame->addHostCallFrameFlag(), argCount, constructor); - DynamicGlobalObjectScope globalObjectScope(newCallFrame, scopeChain->globalObject.get()); + DynamicGlobalObjectScope globalObjectScope(*scopeChain->globalData, scopeChain->globalObject.get()); Profiler** profiler = Profiler::enabledProfilerReference(); if (*profiler) @@ -1066,11 +1066,11 @@ JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSObjec { ASSERT(!scopeChain->globalData->exception); + DynamicGlobalObjectScope globalObjectScope(*scopeChain->globalData, scopeChain->globalObject.get()); + if (m_reentryDepth >= MaxSmallThreadReentryDepth && m_reentryDepth >= callFrame->globalData().maxReentryDepth) return checkedReturn(throwStackOverflowError(callFrame)); - DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject.get()); - JSObject* compileError = eval->compile(callFrame, scopeChain); if (UNLIKELY(!!compileError)) return checkedReturn(throwError(callFrame, compileError)); @@ -1467,8 +1467,8 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi #define CHECK_FOR_EXCEPTION() \ do { \ - if (UNLIKELY(globalData->exception.get() != JSValue())) { \ - exceptionValue = globalData->exception.get(); \ + if (UNLIKELY(globalData->exception != JSValue())) { \ + exceptionValue = globalData->exception; \ goto vm_throw; \ } \ } while (0) @@ -1549,8 +1549,12 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi register dst. */ int dst = vPC[1].u.operand; - int regExp = vPC[2].u.operand; - callFrame->uncheckedR(dst) = JSValue(new (globalData) RegExpObject(callFrame->lexicalGlobalObject(), callFrame->scopeChain()->globalObject->regExpStructure(), codeBlock->regexp(regExp))); + RegExp* regExp = codeBlock->regexp(vPC[2].u.operand); + if (!regExp->isValid()) { + exceptionValue = createSyntaxError(callFrame, "Invalid flags supplied to RegExp constructor."); + goto vm_throw; + } + callFrame->uncheckedR(dst) = JSValue(new (globalData) RegExpObject(callFrame->lexicalGlobalObject(), callFrame->scopeChain()->globalObject->regExpStructure(), regExp)); vPC += OPCODE_LENGTH(op_new_regexp); NEXT_INSTRUCTION(); @@ -3533,10 +3537,9 @@ skip_id_custom_self: to ptr, using pointer equality. */ int src = vPC[1].u.operand; - JSValue ptr = JSValue(vPC[2].u.jsCell); int target = vPC[3].u.operand; JSValue srcValue = callFrame->r(src).jsValue(); - if (srcValue != ptr) { + if (srcValue != vPC[2].u.jsCell.get()) { vPC += target; NEXT_INSTRUCTION(); } @@ -3831,7 +3834,7 @@ skip_id_custom_self: if (thisValue == globalObject && funcVal == globalObject->evalFunction()) { JSValue result = callEval(callFrame, registerFile, argv, argCount, registerOffset); - if ((exceptionValue = globalData->exception.get())) + if ((exceptionValue = globalData->exception)) goto vm_throw; functionReturnValue = result; @@ -4261,7 +4264,7 @@ skip_id_custom_self: Structure* structure; JSValue proto = callFrame->r(protoRegister).jsValue(); if (proto.isObject()) - structure = asObject(proto)->inheritorID(); + structure = asObject(proto)->inheritorID(callFrame->globalData()); else structure = constructor->scope()->globalObject->emptyObjectStructure(); callFrame->uncheckedR(thisRegister) = constructEmptyObject(callFrame, structure); diff --git a/Source/JavaScriptCore/interpreter/Register.h b/Source/JavaScriptCore/interpreter/Register.h index 3944642..fb02c12 100644 --- a/Source/JavaScriptCore/interpreter/Register.h +++ b/Source/JavaScriptCore/interpreter/Register.h @@ -54,11 +54,10 @@ namespace JSC { Register(const JSValue&); Register& operator=(const JSValue&); JSValue jsValue() const; + EncodedJSValue encodedJSValue() const; - Register& operator=(JSActivation*); Register& operator=(CallFrame*); Register& operator=(CodeBlock*); - Register& operator=(JSPropertyNameIterator*); Register& operator=(ScopeChainNode*); Register& operator=(Instruction*); @@ -73,29 +72,17 @@ namespace JSC { static Register withInt(int32_t i) { - Register r; - r.u.i = i; + Register r = jsNumber(i); return r; } - static Register withCallee(JSObject* callee) - { - Register r; - r.u.function = callee; - return r; - } + static inline Register withCallee(JSObject* callee); private: union { - int32_t i; EncodedJSValue value; - - JSActivation* activation; CallFrame* callFrame; CodeBlock* codeBlock; - JSObject* function; - JSPropertyNameIterator* propertyNameIterator; - ScopeChainNode* scopeChain; Instruction* vPC; } u; }; @@ -129,14 +116,13 @@ namespace JSC { return JSValue::decode(u.value); } - // Interpreter functions - - ALWAYS_INLINE Register& Register::operator=(JSActivation* activation) + ALWAYS_INLINE EncodedJSValue Register::encodedJSValue() const { - u.activation = activation; - return *this; + return u.value; } + // Interpreter functions + ALWAYS_INLINE Register& Register::operator=(CallFrame* callFrame) { u.callFrame = callFrame; @@ -155,28 +141,11 @@ namespace JSC { return *this; } - ALWAYS_INLINE Register& Register::operator=(ScopeChainNode* scopeChain) - { - u.scopeChain = scopeChain; - return *this; - } - - ALWAYS_INLINE Register& Register::operator=(JSPropertyNameIterator* propertyNameIterator) - { - u.propertyNameIterator = propertyNameIterator; - return *this; - } - ALWAYS_INLINE int32_t Register::i() const { - return u.i; + return jsValue().asInt32(); } - - ALWAYS_INLINE JSActivation* Register::activation() const - { - return u.activation; - } - + ALWAYS_INLINE CallFrame* Register::callFrame() const { return u.callFrame; @@ -186,22 +155,7 @@ namespace JSC { { return u.codeBlock; } - - ALWAYS_INLINE JSObject* Register::function() const - { - return u.function; - } - - ALWAYS_INLINE JSPropertyNameIterator* Register::propertyNameIterator() const - { - return u.propertyNameIterator; - } - - ALWAYS_INLINE ScopeChainNode* Register::scopeChain() const - { - return u.scopeChain; - } - + ALWAYS_INLINE Instruction* Register::vPC() const { return u.vPC; diff --git a/Source/JavaScriptCore/interpreter/RegisterFile.cpp b/Source/JavaScriptCore/interpreter/RegisterFile.cpp index 47f0c18..b3a87e5 100644 --- a/Source/JavaScriptCore/interpreter/RegisterFile.cpp +++ b/Source/JavaScriptCore/interpreter/RegisterFile.cpp @@ -29,6 +29,7 @@ #include "config.h" #include "RegisterFile.h" +#include "ConservativeSet.h" #include "Interpreter.h" #include "JSGlobalData.h" #include "JSGlobalObject.h" @@ -51,6 +52,16 @@ RegisterFile::~RegisterFile() m_reservation.deallocate(); } +void RegisterFile::gatherConservativeRoots(ConservativeRoots& conservativeRoots) +{ + for (Register* it = start(); it != end(); ++it) { + JSValue v = it->jsValue(); + if (!v.isCell()) + continue; + conservativeRoots.add(v.asCell()); + } +} + void RegisterFile::releaseExcessCapacity() { m_reservation.decommit(m_start, reinterpret_cast(m_commitEnd) - reinterpret_cast(m_start)); diff --git a/Source/JavaScriptCore/interpreter/RegisterFile.h b/Source/JavaScriptCore/interpreter/RegisterFile.h index bb42902..4d04085 100644 --- a/Source/JavaScriptCore/interpreter/RegisterFile.h +++ b/Source/JavaScriptCore/interpreter/RegisterFile.h @@ -91,7 +91,6 @@ namespace JSC { class RegisterFile { WTF_MAKE_NONCOPYABLE(RegisterFile); - friend class JIT; public: enum CallFrameHeaderEntry { CallFrameHeaderSize = 6, @@ -114,6 +113,8 @@ namespace JSC { RegisterFile(JSGlobalData&, size_t capacity = defaultCapacity, size_t maxGlobals = defaultMaxGlobals); ~RegisterFile(); + + void gatherConservativeRoots(ConservativeRoots&); Register* start() const { return m_start; } Register* end() const { return m_end; } @@ -136,6 +137,11 @@ namespace JSC { static Finalizer* globalObjectCollectedNotifier(); + Register* const * addressOfEnd() const + { + return &m_end; + } + private: void releaseExcessCapacity(); void addToCommittedByteCount(long); -- cgit v1.1