Skip to content

Commit

Permalink
Roll out r37427 because it causes an infinite recursion loading about…
Browse files Browse the repository at this point in the history
  • Loading branch information
xeenon committed Oct 8, 2008
1 parent 09b6914 commit 8e8c2e5
Show file tree
Hide file tree
Showing 41 changed files with 1,364 additions and 1,324 deletions.
12 changes: 6 additions & 6 deletions JavaScriptCore/API/JSObjectRef.cpp
Expand Up @@ -92,7 +92,7 @@ JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name,
exec->globalData().heap.registerThread();
JSLock lock(exec);

Identifier nameID = name ? name->identifier(&exec->globalData()) : Identifier(exec, "anonymous");
Identifier nameID = name ? name->identifier(exec) : Identifier(exec, "anonymous");

return toRef(new (exec) JSCallbackFunction(exec, callAsFunction, nameID));
}
Expand All @@ -118,7 +118,7 @@ JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned pa
exec->globalData().heap.registerThread();
JSLock lock(exec);

Identifier nameID = name ? name->identifier(&exec->globalData()) : Identifier(exec, "anonymous");
Identifier nameID = name ? name->identifier(exec) : Identifier(exec, "anonymous");

ArgList args;
for (unsigned i = 0; i < parameterCount; i++)
Expand Down Expand Up @@ -246,7 +246,7 @@ bool JSObjectHasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef prope

JSObject* jsObject = toJS(object);

return jsObject->hasProperty(exec, propertyName->identifier(&exec->globalData()));
return jsObject->hasProperty(exec, propertyName->identifier(exec));
}

JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
Expand All @@ -257,7 +257,7 @@ JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef

JSObject* jsObject = toJS(object);

JSValue* jsValue = jsObject->get(exec, propertyName->identifier(&exec->globalData()));
JSValue* jsValue = jsObject->get(exec, propertyName->identifier(exec));
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
Expand All @@ -273,7 +273,7 @@ void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef prope
JSLock lock(exec);

JSObject* jsObject = toJS(object);
Identifier name(propertyName->identifier(&exec->globalData()));
Identifier name(propertyName->identifier(exec));
JSValue* jsValue = toJS(value);

if (attributes && !jsObject->hasProperty(exec, name))
Expand Down Expand Up @@ -333,7 +333,7 @@ bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef pr

JSObject* jsObject = toJS(object);

bool result = jsObject->deleteProperty(exec, propertyName->identifier(&exec->globalData()));
bool result = jsObject->deleteProperty(exec, propertyName->identifier(exec));
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
Expand Down
5 changes: 5 additions & 0 deletions JavaScriptCore/API/OpaqueJSString.cpp
Expand Up @@ -46,6 +46,11 @@ UString OpaqueJSString::ustring() const
return UString::null();
}

Identifier OpaqueJSString::identifier(ExecState* exec) const
{
return identifier(&exec->globalData());
}

Identifier OpaqueJSString::identifier(JSGlobalData* globalData) const
{
if (!this || !m_characters)
Expand Down
5 changes: 4 additions & 1 deletion JavaScriptCore/API/OpaqueJSString.h
Expand Up @@ -29,9 +29,10 @@
#include <kjs/ustring.h>

namespace JSC {
class ExecState;
class Identifier;
class JSGlobalData;
}
};

struct OpaqueJSString : public ThreadSafeShared<OpaqueJSString> {

Expand All @@ -51,6 +52,8 @@ struct OpaqueJSString : public ThreadSafeShared<OpaqueJSString> {
unsigned length() { return this ? m_length : 0; }

JSC::UString ustring() const;

JSC::Identifier identifier(JSC::ExecState*) const;
JSC::Identifier identifier(JSC::JSGlobalData*) const;

private:
Expand Down
6 changes: 6 additions & 0 deletions JavaScriptCore/ChangeLog
@@ -1,3 +1,9 @@
2008-10-08 Timothy Hatcher <timothy@apple.com>

Roll out r37427 because it causes an infinite recursion loading about:blank.

https://bugs.webkit.org/show_bug.cgi?id=21476

2008-10-08 Darin Adler <darin@apple.com>

Reviewed by Cameron Zwarich.
Expand Down
69 changes: 31 additions & 38 deletions JavaScriptCore/VM/CTI.cpp
Expand Up @@ -34,7 +34,6 @@
#include "Machine.h"
#include "wrec/WREC.h"
#include "ResultType.h"

#if PLATFORM(MAC)
#include <sys/sysctl.h>
#endif
Expand All @@ -44,15 +43,12 @@ using namespace std;
namespace JSC {

#if PLATFORM(MAC)

static inline bool isSSE2Present()
bool isSSE2Present()
{
return true; // All X86 Macs are guaranteed to support at least SSE2
}

#else

static bool isSSE2Present()
#else COMPILER(MSVC)
bool isSSE2Present()
{
static const int SSE2FeatureBit = 1 << 26;
struct SSE2Check {
Expand All @@ -76,12 +72,8 @@ static bool isSSE2Present()
static SSE2Check check;
return check.present;
}

#endif

COMPILE_ASSERT(CTI_ARGS_code == 0xC, CTI_ARGS_code_is_C);
COMPILE_ASSERT(CTI_ARGS_callFrame == 0xE, CTI_ARGS_callFrame_is_E);

#if COMPILER(GCC) && PLATFORM(X86)

asm(
Expand All @@ -91,8 +83,8 @@ asm(
"pushl %edi" "\n"
"subl $0x24, %esp" "\n"
"movl $512, %esi" "\n"
"movl 0x38(%esp), %edi" "\n" // Ox38 = 0x0E * 4, 0x0E = CTI_ARGS_callFrame (see assertion above)
"call *0x30(%esp)" "\n" // Ox30 = 0x0C * 4, 0x0C = CTI_ARGS_code (see assertion above)
"movl 0x38(%esp), %edi" "\n" // Ox38 = 0x0E * 4, 0x0E = CTI_ARGS_r
"call *0x30(%esp)" "\n" // Ox30 = 0x0C * 4, 0x0C = CTI_ARGS_code
"addl $0x24, %esp" "\n"
"popl %edi" "\n"
"popl %esi" "\n"
Expand Down Expand Up @@ -122,7 +114,7 @@ extern "C" {
mov esi, 512;
mov ecx, esp;
mov edi, [esp + 0x38];
call [esp + 0x30]; // Ox30 = 0x0C * 4, 0x0C = CTI_ARGS_code (see assertion above)
call [esp + 0x30];
add esp, 0x24;
pop edi;
pop esi;
Expand All @@ -146,22 +138,23 @@ extern "C" {

#endif


ALWAYS_INLINE bool CTI::isConstant(int src)
{
return src >= m_codeBlock->numVars && src < m_codeBlock->numVars + m_codeBlock->numConstants;
}

ALWAYS_INLINE JSValue* CTI::getConstant(CallFrame* callFrame, int src)
ALWAYS_INLINE JSValue* CTI::getConstant(ExecState* exec, int src)
{
return m_codeBlock->constantRegisters[src - m_codeBlock->numVars].jsValue(callFrame);
return m_codeBlock->constantRegisters[src - m_codeBlock->numVars].jsValue(exec);
}

// get arg puts an arg from the SF register array into a h/w register
ALWAYS_INLINE void CTI::emitGetArg(int src, X86Assembler::RegisterID dst)
{
// TODO: we want to reuse values that are already in registers if we can - add a register allocator!
if (isConstant(src)) {
JSValue* js = getConstant(m_callFrame, src);
JSValue* js = getConstant(m_exec, src);
m_jit.movl_i32r(reinterpret_cast<unsigned>(js), dst);
} else
m_jit.movl_mr(src * sizeof(Register), X86::edi, dst);
Expand All @@ -171,7 +164,7 @@ ALWAYS_INLINE void CTI::emitGetArg(int src, X86Assembler::RegisterID dst)
ALWAYS_INLINE void CTI::emitGetPutArg(unsigned src, unsigned offset, X86Assembler::RegisterID scratch)
{
if (isConstant(src)) {
JSValue* js = getConstant(m_callFrame, src);
JSValue* js = getConstant(m_exec, src);
m_jit.movl_i32m(reinterpret_cast<unsigned>(js), offset + sizeof(void*), X86::esp);
} else {
m_jit.movl_mr(src * sizeof(Register), X86::edi, scratch);
Expand All @@ -193,7 +186,7 @@ ALWAYS_INLINE void CTI::emitPutArgConstant(unsigned value, unsigned offset)
ALWAYS_INLINE JSValue* CTI::getConstantImmediateNumericArg(unsigned src)
{
if (isConstant(src)) {
JSValue* js = getConstant(m_callFrame, src);
JSValue* js = getConstant(m_exec, src);
return JSImmediate::isNumber(js) ? js : 0;
}
return 0;
Expand Down Expand Up @@ -256,7 +249,7 @@ void CTI::printOpcodeOperandTypes(unsigned src1, unsigned src2)
{
char which1 = '*';
if (isConstant(src1)) {
JSValue* js = getConstant(m_callFrame, src1);
JSValue* js = getConstant(m_exec, src1);
which1 =
JSImmediate::isImmediate(js) ?
(JSImmediate::isNumber(js) ? 'i' :
Expand All @@ -270,7 +263,7 @@ void CTI::printOpcodeOperandTypes(unsigned src1, unsigned src2)
}
char which2 = '*';
if (isConstant(src2)) {
JSValue* js = getConstant(m_callFrame, src2);
JSValue* js = getConstant(m_exec, src2);
which2 =
JSImmediate::isImmediate(js) ?
(JSImmediate::isNumber(js) ? 'i' :
Expand Down Expand Up @@ -452,10 +445,10 @@ ALWAYS_INLINE void CTI::emitTagAsBoolImmediate(X86Assembler::RegisterID reg)
m_jit.orl_i32r(JSImmediate::FullTagTypeBool, reg);
}

CTI::CTI(Machine* machine, CallFrame* callFrame, CodeBlock* codeBlock)
CTI::CTI(Machine* machine, ExecState* exec, CodeBlock* codeBlock)
: m_jit(machine->jitCodeBuffer())
, m_machine(machine)
, m_callFrame(callFrame)
, m_exec(exec)
, m_codeBlock(codeBlock)
, m_labels(codeBlock ? codeBlock->instructions.size() : 0)
, m_structureStubCompilationInfo(codeBlock ? codeBlock->structureIDInstructions.size() : 0)
Expand Down Expand Up @@ -494,7 +487,7 @@ void CTI::compileOpCallInitializeCallFrame(unsigned callee, unsigned argCount)

m_jit.movl_mr(OBJECT_OFFSET(JSFunction, m_scopeChain) + OBJECT_OFFSET(ScopeChain, m_node), X86::ecx, X86::ecx); // newScopeChain
m_jit.movl_i32m(argCount, RegisterFile::ArgumentCount * static_cast<int>(sizeof(Register)), X86::edx);
m_jit.movl_rm(X86::edi, RegisterFile::CallerFrame * static_cast<int>(sizeof(Register)), X86::edx);
m_jit.movl_rm(X86::edi, RegisterFile::CallerRegisters * static_cast<int>(sizeof(Register)), X86::edx);
m_jit.movl_rm(X86::ecx, RegisterFile::ScopeChain * static_cast<int>(sizeof(Register)), X86::edx);
}

Expand Down Expand Up @@ -522,8 +515,8 @@ void CTI::compileOpCall(Instruction* instruction, unsigned i, CompileOpCallType

int thisVal = instruction[i + 3].u.operand;
if (thisVal == missingThisObjectMarker()) {
// FIXME: should this be loaded dynamically off m_callFrame?
m_jit.movl_i32m(reinterpret_cast<unsigned>(m_callFrame->globalThisValue()), firstArg * sizeof(Register), X86::edi);
// FIXME: should this be loaded dynamically off m_exec?
m_jit.movl_i32m(reinterpret_cast<unsigned>(m_exec->globalThisValue()), firstArg * sizeof(Register), X86::edi);
} else {
emitGetArg(thisVal, X86::ecx);
emitPutResult(firstArg, X86::ecx);
Expand Down Expand Up @@ -566,8 +559,8 @@ void CTI::compileOpCall(Instruction* instruction, unsigned i, CompileOpCallType
// load ctiCode from the new codeBlock.
m_jit.movl_mr(OBJECT_OFFSET(CodeBlock, ctiCode), X86::eax, X86::eax);

// Put the new value of 'callFrame' into edi and onto the stack, too.
emitPutCTIParam(X86::edx, CTI_ARGS_callFrame);
// Setup the new value of 'r' in edi, and on the stack, too.
emitPutCTIParam(X86::edx, CTI_ARGS_r);
m_jit.movl_rr(X86::edx, X86::edi);

// Check the ctiCode has been generated - if not, this is handled in a slow case.
Expand Down Expand Up @@ -692,7 +685,7 @@ void CTI::putDoubleResultToJSNumberCellOrJSImmediate(X86::XMMRegisterID xmmSourc

void CTI::compileBinaryArithOp(OpcodeID opcodeID, unsigned dst, unsigned src1, unsigned src2, OperandTypes types, unsigned i)
{
StructureID* numberStructureID = m_callFrame->globalData().numberStructureID.get();
StructureID* numberStructureID = m_exec->globalData().numberStructureID.get();
X86Assembler::JmpSrc wasJSNumberCell1, wasJSNumberCell1b, wasJSNumberCell2, wasJSNumberCell2b;

emitGetArg(src1, X86::eax);
Expand Down Expand Up @@ -885,7 +878,7 @@ void CTI::privateCompileMainPass()
case op_mov: {
unsigned src = instruction[i + 2].u.operand;
if (isConstant(src))
m_jit.movl_i32r(reinterpret_cast<unsigned>(getConstant(m_callFrame, src)), X86::edx);
m_jit.movl_i32r(reinterpret_cast<unsigned>(getConstant(m_exec, src)), X86::edx);
else
emitGetArg(src, X86::edx);
emitPutResult(instruction[i + 1].u.operand, X86::edx);
Expand Down Expand Up @@ -1245,8 +1238,8 @@ void CTI::privateCompileMainPass()
emitGetArg(RegisterFile::ReturnPC, X86::edx);

// Restore our caller's "r".
emitGetArg(RegisterFile::CallerFrame, X86::edi);
emitPutCTIParam(X86::edi, CTI_ARGS_callFrame);
emitGetArg(RegisterFile::CallerRegisters, X86::edi);
emitPutCTIParam(X86::edi, CTI_ARGS_r);

// Return.
m_jit.pushl_r(X86::edx);
Expand Down Expand Up @@ -1810,7 +1803,7 @@ void CTI::privateCompileMainPass()
break;
}
case op_catch: {
emitGetCTIParam(CTI_ARGS_callFrame, X86::edi); // edi := r
emitGetCTIParam(CTI_ARGS_r, X86::edi); // edi := r
emitPutResult(instruction[i + 1].u.operand);
i += 2;
break;
Expand Down Expand Up @@ -2659,7 +2652,7 @@ void CTI::privateCompileGetByIdProto(StructureID* structureID, StructureID* prot

// The prototype object definitely exists (if this stub exists the CodeBlock is referencing a StructureID that is
// referencing the prototype object - let's speculatively load it's table nice and early!)
JSObject* protoObject = static_cast<JSObject*>(structureID->prototypeForLookup(m_callFrame));
JSObject* protoObject = static_cast<JSObject*>(structureID->prototypeForLookup(m_exec));
PropertyStorage* protoPropertyStorage = &protoObject->m_propertyStorage;
m_jit.movl_mr(static_cast<void*>(protoPropertyStorage), X86::edx);

Expand Down Expand Up @@ -2702,7 +2695,7 @@ void CTI::privateCompileGetByIdProto(StructureID* structureID, StructureID* prot
#else
// The prototype object definitely exists (if this stub exists the CodeBlock is referencing a StructureID that is
// referencing the prototype object - let's speculatively load it's table nice and early!)
JSObject* protoObject = static_cast<JSObject*>(structureID->prototypeForLookup(m_callFrame));
JSObject* protoObject = static_cast<JSObject*>(structureID->prototypeForLookup(m_exec));
PropertyStorage* protoPropertyStorage = &protoObject->m_propertyStorage;
m_jit.movl_mr(static_cast<void*>(protoPropertyStorage), X86::edx);

Expand Down Expand Up @@ -2751,7 +2744,7 @@ void CTI::privateCompileGetByIdChain(StructureID* structureID, StructureIDChain*
RefPtr<StructureID>* chainEntries = chain->head();
JSObject* protoObject = 0;
for (unsigned i = 0; i<count; ++i) {
protoObject = static_cast<JSObject*>(currStructureID->prototypeForLookup(m_callFrame));
protoObject = static_cast<JSObject*>(currStructureID->prototypeForLookup(m_exec));
currStructureID = chainEntries[i].get();

// Check the prototype object's StructureID had not changed.
Expand Down Expand Up @@ -3051,15 +3044,15 @@ void CTI::emitPutVariableObjectRegister(X86Assembler::RegisterID src, X86Assembl

#if ENABLE(WREC)

void* CTI::compileRegExp(Machine* machine, const UString& pattern, unsigned* numSubpatterns_ptr, const char** error_ptr, bool ignoreCase, bool multiline)
void* CTI::compileRegExp(ExecState* exec, const UString& pattern, unsigned* numSubpatterns_ptr, const char** error_ptr, bool ignoreCase, bool multiline)
{
// TODO: better error messages
if (pattern.size() > MaxPatternSize) {
*error_ptr = "regular expression too large";
return 0;
}

X86Assembler jit(machine->jitCodeBuffer());
X86Assembler jit(exec->machine()->jitCodeBuffer());
WRECParser parser(pattern, ignoreCase, multiline, jit);

jit.emitConvertToFastCall();
Expand Down

0 comments on commit 8e8c2e5

Please sign in to comment.