Commit 960c28e7 authored by ap@webkit.org's avatar ap@webkit.org

Reviewed by Darin.

        Prepare JavaScript heap for being per-thread.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34659 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e1450a3d
......@@ -28,6 +28,7 @@
#include "JSBase.h"
#include "APICast.h"
#include "completion.h"
#include <kjs/ExecState.h>
#include <kjs/InitializeThreading.h>
#include <kjs/interpreter.h>
......@@ -85,9 +86,21 @@ void JSGarbageCollect(JSContextRef ctx)
if (!ctx)
initializeThreading();
// It might seem that we have a context passed to this function, and can use toJS(ctx)->heap(), but the parameter is likely to be NULL,
// and it may actually be garbage for some clients (most likely, because of JSGarbageCollect being called after releasing the context).
JSLock lock;
if (!Collector::isBusy())
Collector::collect();
// FIXME: It would be good to avoid creating a JSGlobalData instance if it didn't exist for this thread yet.
Heap* heap = JSGlobalData::threadInstance().heap;
if (!heap->isBusy())
heap->collect();
// FIXME: Similarly, we shouldn't create a shared instance here.
heap = JSGlobalData::sharedInstance().heap;
if (!heap->isBusy())
heap->collect();
// FIXME: Perhaps we should trigger a second mark and sweep
// once the garbage collector is done if this is called when
// the collector is busy.
......
......@@ -470,7 +470,7 @@ JSValue* JSCallbackObject<Base>::staticFunctionGetter(ExecState* exec, const Ide
if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) {
JSObject* o = new JSCallbackFunction(exec, callAsFunction, propertyName);
JSObject* o = new (exec) JSCallbackFunction(exec, callAsFunction, propertyName);
thisObj->putDirect(propertyName, o, entry->attributes);
return o;
}
......
......@@ -162,7 +162,7 @@ JSObject* OpaqueJSClass::prototype(JSContextRef ctx)
parentPrototype = parentClass->prototype(ctx); // can be null
if (!parentPrototype)
parentPrototype = exec->dynamicGlobalObject()->objectPrototype();
cachedPrototype = new JSCallbackObject<JSObject>(exec, prototypeClass, parentPrototype, this); // set ourself as the object's private data, so it can clear our reference on destruction
cachedPrototype = new (exec) JSCallbackObject<JSObject>(exec, prototypeClass, parentPrototype, this); // set ourself as the object's private data, so it can clear our reference on destruction
}
return cachedPrototype;
}
......@@ -44,11 +44,11 @@ JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass)
JSLock lock;
if (!globalObjectClass) {
JSGlobalObject* globalObject = new JSGlobalObject;
JSGlobalObject* globalObject = new (JSGlobalObject::Shared) JSGlobalObject;
return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec()));
}
JSGlobalObject* globalObject = new JSCallbackObject<JSGlobalObject>(globalObjectClass);
JSGlobalObject* globalObject = new (JSGlobalObject::Shared) JSCallbackObject<JSGlobalObject>(globalObjectClass);
JSGlobalContextRef ctx = toGlobalRef(globalObject->globalExec());
JSValue* prototype = globalObjectClass->prototype(ctx);
if (!prototype)
......
......@@ -74,13 +74,13 @@ JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data)
ExecState* exec = toJS(ctx);
if (!jsClass)
return toRef(new JSObject(exec->lexicalGlobalObject()->objectPrototype())); // slightly more efficient
return toRef(new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype())); // slightly more efficient
JSValue* jsPrototype = jsClass->prototype(ctx);
if (!jsPrototype)
jsPrototype = exec->lexicalGlobalObject()->objectPrototype();
return toRef(new JSCallbackObject<JSObject>(exec, jsClass, jsPrototype, data));
return toRef(new (exec) JSCallbackObject<JSObject>(exec, jsClass, jsPrototype, data));
}
JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction)
......@@ -89,7 +89,7 @@ JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name,
ExecState* exec = toJS(ctx);
Identifier nameID = name ? Identifier(exec, toJS(name)) : Identifier(exec, "anonymous");
return toRef(new JSCallbackFunction(exec, callAsFunction, nameID));
return toRef(new (exec) JSCallbackFunction(exec, callAsFunction, nameID));
}
JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor)
......@@ -101,7 +101,7 @@ JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObje
? jsClass->prototype(ctx)
: exec->dynamicGlobalObject()->objectPrototype();
JSCallbackConstructor* constructor = new JSCallbackConstructor(exec, jsClass, callAsConstructor);
JSCallbackConstructor* constructor = new (exec) JSCallbackConstructor(exec, jsClass, callAsConstructor);
constructor->putDirect(exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly);
return toRef(constructor);
}
......@@ -118,8 +118,8 @@ JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned pa
ArgList args;
for (unsigned i = 0; i < parameterCount; i++)
args.append(jsString(UString(toJS(parameterNames[i]))));
args.append(jsString(UString(bodyRep)));
args.append(jsString(exec, UString(toJS(parameterNames[i]))));
args.append(jsString(exec, UString(bodyRep)));
JSObject* result = exec->dynamicGlobalObject()->functionConstructor()->construct(exec, args, nameID, UString(sourceURLRep), startingLineNumber);
if (exec->hadException()) {
......
......@@ -176,17 +176,17 @@ JSValueRef JSValueMakeBoolean(JSContextRef, bool value)
return toRef(jsBoolean(value));
}
JSValueRef JSValueMakeNumber(JSContextRef, double value)
JSValueRef JSValueMakeNumber(JSContextRef ctx, double value)
{
JSLock lock;
return toRef(jsNumber(value));
return toRef(jsNumber(toJS(ctx), value));
}
JSValueRef JSValueMakeString(JSContextRef, JSStringRef string)
JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string)
{
JSLock lock;
UString::Rep* rep = toJS(string);
return toRef(jsString(UString(rep)));
return toRef(jsString(toJS(ctx), UString(rep)));
}
bool JSValueToBoolean(JSContextRef ctx, JSValueRef value)
......
This diff is collapsed.
......@@ -97,6 +97,7 @@ __ZN3KJS11PropertyMap11getLocationERKNS_10IdentifierERb
__ZN3KJS11PropertyMap3putERKNS_10IdentifierEPNS_7JSValueEjb
__ZN3KJS11PropertyMapD1Ev
__ZN3KJS12DateInstance4infoE
__ZN3KJS12JSGlobalData14sharedInstanceEv
__ZN3KJS12JSGlobalData14threadInstanceEv
__ZN3KJS12PropertySlot15undefinedGetterEPNS_9ExecStateERKNS_10IdentifierERKS0_
__ZN3KJS12RegisterFile14addGlobalSlotsEm
......@@ -106,10 +107,10 @@ __ZN3KJS12StringObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_
__ZN3KJS12StringObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
__ZN3KJS12StringObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueE
__ZN3KJS12StringObject4infoE
__ZN3KJS12StringObjectC2EPNS_8JSObjectERKNS_7UStringE
__ZN3KJS12StringObjectC2EPNS_9ExecStateEPNS_8JSObjectERKNS_7UStringE
__ZN3KJS13CodeGenerator21setDumpsGeneratedCodeEb
__ZN3KJS13StatementNode6setLocEii
__ZN3KJS13jsOwnedStringERKNS_7UStringE
__ZN3KJS13jsOwnedStringEPNS_9ExecStateERKNS_7UStringE
__ZN3KJS14JSGlobalObject10globalExecEv
__ZN3KJS14JSGlobalObject12defineGetterEPNS_9ExecStateERKNS_10IdentifierEPNS_8JSObjectE
__ZN3KJS14JSGlobalObject12defineSetterEPNS_9ExecStateERKNS_10IdentifierEPNS_8JSObjectE
......@@ -120,6 +121,8 @@ __ZN3KJS14JSGlobalObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueE
__ZN3KJS14JSGlobalObject4initEPNS_8JSObjectE
__ZN3KJS14JSGlobalObject4markEv
__ZN3KJS14JSGlobalObjectD2Ev
__ZN3KJS14JSGlobalObjectnwEm
__ZN3KJS14JSGlobalObjectnwEmNS0_9SharedTagE
__ZN3KJS15JSWrapperObject4markEv
__ZN3KJS16InternalFunction11getCallDataERNS_8CallDataE
__ZN3KJS16InternalFunction4infoE
......@@ -134,6 +137,19 @@ __ZN3KJS17PrototypeFunctionC1EPNS_9ExecStateEiRKNS_10IdentifierEPFPNS_7JSValueES
__ZN3KJS17RegisterFileStack20allocateRegisterFileEmPS0_
__ZN3KJS19initializeThreadingEv
__ZN3KJS23objectProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_7ArgListE
__ZN3KJS4Heap14allocateNumberEm
__ZN3KJS4Heap15recordExtraCostEm
__ZN3KJS4Heap17globalObjectCountEv
__ZN3KJS4Heap20protectedObjectCountEv
__ZN3KJS4Heap23collectOnMainThreadOnlyEPNS_7JSValueE
__ZN3KJS4Heap25protectedObjectTypeCountsEv
__ZN3KJS4Heap26protectedGlobalObjectCountEv
__ZN3KJS4Heap4heapEPKNS_7JSValueE
__ZN3KJS4Heap4sizeEv
__ZN3KJS4Heap7collectEv
__ZN3KJS4Heap7protectEPNS_7JSValueE
__ZN3KJS4Heap8allocateEm
__ZN3KJS4Heap9unprotectEPNS_7JSValueE
__ZN3KJS5equalEPKNS_7UString3RepES3_
__ZN3KJS6JSCell11getCallDataERNS_8CallDataE
__ZN3KJS6JSCell16getConstructDataERNS_13ConstructDataE
......@@ -142,7 +158,7 @@ __ZN3KJS6JSCell18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
__ZN3KJS6JSCell3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueE
__ZN3KJS6JSCell3putEPNS_9ExecStateEjPNS_7JSValueE
__ZN3KJS6JSCell9getObjectEv
__ZN3KJS6JSCellnwEm
__ZN3KJS6JSCellnwEmPNS_9ExecStateE
__ZN3KJS6JSLock12DropAllLocksC1Ev
__ZN3KJS6JSLock12DropAllLocksD1Ev
__ZN3KJS6JSLock14registerThreadEv
......@@ -196,19 +212,8 @@ __ZN3KJS8JSObject9constructEPNS_9ExecStateERKNS_7ArgListERKNS_10IdentifierERKNS_
__ZN3KJS8Profiler13stopProfilingEPNS_9ExecStateERKNS_7UStringE
__ZN3KJS8Profiler14startProfilingEPNS_9ExecStateERKNS_7UStringE
__ZN3KJS8Profiler8profilerEv
__ZN3KJS8jsStringEPKc
__ZN3KJS8jsStringERKNS_7UStringE
__ZN3KJS9Collector14allocateNumberEm
__ZN3KJS9Collector15recordExtraCostEm
__ZN3KJS9Collector17globalObjectCountEv
__ZN3KJS9Collector20protectedObjectCountEv
__ZN3KJS9Collector23collectOnMainThreadOnlyEPNS_7JSValueE
__ZN3KJS9Collector25protectedObjectTypeCountsEv
__ZN3KJS9Collector26protectedGlobalObjectCountEv
__ZN3KJS9Collector4sizeEv
__ZN3KJS9Collector7collectEv
__ZN3KJS9Collector7protectEPNS_7JSValueE
__ZN3KJS9Collector9unprotectEPNS_7JSValueE
__ZN3KJS8jsStringEPNS_9ExecStateEPKc
__ZN3KJS8jsStringEPNS_9ExecStateERKNS_7UStringE
__ZN3KJSeqERKNS_7UStringEPKc
__ZN3KJSgtERKNS_7UStringES2_
__ZN3KJSltERKNS_7UStringES2_
......@@ -246,9 +251,9 @@ __ZNK3KJS14JSGlobalObject14toGlobalObjectEPNS_9ExecStateE
__ZNK3KJS16InternalFunction21implementsHasInstanceEv
__ZNK3KJS16JSVariableObject16isVariableObjectEv
__ZNK3KJS16JSVariableObject21getPropertyAttributesEPNS_9ExecStateERKNS_10IdentifierERj
__ZNK3KJS17DebuggerCallFrame4typeEv
__ZNK3KJS17DebuggerCallFrame10thisObjectEv
__ZNK3KJS17DebuggerCallFrame12functionNameEv
__ZNK3KJS17DebuggerCallFrame4typeEv
__ZNK3KJS17DebuggerCallFrame8evaluateERKNS_7UStringERPNS_7JSValueE
__ZNK3KJS4Node8toStringEv
__ZNK3KJS6JSCell12toThisObjectEPNS_9ExecStateE
......
......@@ -102,7 +102,6 @@
14D797800DAC3307001A9F05 /* RegisterFileStack.h in Headers */ = {isa = PBXBuildFile; fileRef = 14D7977E0DAC3307001A9F05 /* RegisterFileStack.h */; settings = {ATTRIBUTES = (Private, ); }; };
14D797810DAC3307001A9F05 /* RegisterFileStack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14D7977F0DAC3307001A9F05 /* RegisterFileStack.cpp */; };
14DA81900D99FD2000B0A4FB /* JSActivation.h in Headers */ = {isa = PBXBuildFile; fileRef = 14DA818E0D99FD2000B0A4FB /* JSActivation.h */; };
14DE0D690D02431400AACCA2 /* JSGlobalObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14DE0D680D02431400AACCA2 /* JSGlobalObject.cpp */; };
14E0FF120DBAAED00007C0AB /* Machine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 149B15E70D81F986009CB8C7 /* Machine.cpp */; settings = {COMPILER_FLAGS = "-fno-tree-pre"; }; };
14F252570D08DD8D004ECFFF /* JSVariableObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 14F252560D08DD8D004ECFFF /* JSVariableObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
14F252610D08DF2F004ECFFF /* JSVariableObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14F252600D08DF2F004ECFFF /* JSVariableObject.cpp */; };
......@@ -1539,7 +1538,6 @@
140B7D1D0DC69AF7009C42B8 /* JSActivation.cpp in Sources */,
1440FCE40A51E46B0005F061 /* JSClassRef.cpp in Sources */,
14BD5A300A3E91F600BAF59C /* JSContextRef.cpp in Sources */,
14DE0D690D02431400AACCA2 /* JSGlobalObject.cpp in Sources */,
1482B7E40A43076000517CFC /* JSObjectRef.cpp in Sources */,
1482B74E0A43032800517CFC /* JSStringRef.cpp in Sources */,
146AAB380B66A94400E55F16 /* JSStringRefCF.cpp in Sources */,
......
......@@ -568,7 +568,7 @@ RegisterID* CodeGenerator::emitLoad(RegisterID* dst, double d)
{
emitOpcode(op_load);
instructions().append(dst->index());
instructions().append(addConstant(jsNumber(d)));
instructions().append(addConstant(jsNumber(globalExec(), d)));
return dst;
}
......
......@@ -278,6 +278,8 @@ namespace KJS {
CodeType codeType() const { return m_codeType; }
ExecState* globalExec() { return m_scopeChain->globalObject()->globalExec(); }
private:
void emitOpcode(OpcodeID);
void retrieveLastBinaryOp(int& dstIndex, int& src1Index, int& src2Index);
......
......@@ -40,13 +40,13 @@ COMPILE_ASSERT(sizeof(JSPropertyNameIterator) <= CellSize<sizeof(void*)>::m_valu
JSPropertyNameIterator* JSPropertyNameIterator::create(ExecState* exec, JSValue* v)
{
if (v->isUndefinedOrNull())
return new JSPropertyNameIterator(0, 0, 0);
return new (exec) JSPropertyNameIterator(0, 0, 0);
JSObject* o = v->toObject(exec);
PropertyNameArray propertyNames(exec);
o->getPropertyNames(exec, propertyNames);
size_t numProperties = propertyNames.size();
return new JSPropertyNameIterator(o, propertyNames.releaseIdentifiers(), numProperties);
return new (exec) JSPropertyNameIterator(o, propertyNames.releaseIdentifiers(), numProperties);
}
JSPropertyNameIterator::JSPropertyNameIterator(JSObject* object, Identifier* propertyNames, size_t numProperties)
......@@ -114,7 +114,7 @@ JSValue* JSPropertyNameIterator::next(ExecState* exec)
{
while (m_position != m_end) {
if (m_object->hasProperty(exec, *m_position))
return jsOwnedString((*m_position++).ustring());;
return jsOwnedString(exec, (*m_position++).ustring());;
m_position++;
}
invalidate();
......
This diff is collapsed.
......@@ -136,9 +136,9 @@ namespace KJS {
void copyGlobals(RegisterFile* src);
void mark()
void mark(Heap* heap)
{
Collector::markStackObjectsConservatively(m_buffer, m_base + m_size);
heap->markStackObjectsConservatively(m_buffer, m_base + m_size);
}
bool isGlobal() { return !!m_baseObserver; }
......
......@@ -51,11 +51,11 @@ namespace KJS {
RegisterFile* current() { return m_stack.last(); }
void mark()
void mark(Heap* heap)
{
Stack::iterator end = m_stack.end();
for (Stack::iterator it = m_stack.begin(); it != end; ++it)
(*it)->mark();
(*it)->mark(heap);
}
// Pointer to a value that holds the base of the top-most global register file.
......
......@@ -56,6 +56,7 @@
#include "nodes2string.cpp"
#include "NumberObject.cpp"
#include "JSObject.cpp"
#include "JSGlobalObject.cpp"
#include "object_object.cpp"
#include "operations.cpp"
#include "Parser.cpp"
......
This diff is collapsed.
......@@ -50,8 +50,8 @@ BooleanPrototype::BooleanPrototype(ExecState* exec, ObjectPrototype* objectProto
{
setInternalValue(jsBoolean(false));
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);
putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);
putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);
}
......@@ -67,7 +67,7 @@ JSValue* booleanProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgL
JSValue* v = static_cast<BooleanObject*>(thisObj)->internalValue();
ASSERT(v);
return jsString(v->toString(exec));
return jsString(exec, v->toString(exec));
}
JSValue* booleanProtoFuncValueOf(ExecState* exec, JSObject* thisObj, const ArgList&)
{
......@@ -90,7 +90,7 @@ BooleanConstructor::BooleanConstructor(ExecState* exec, FunctionPrototype* funct
putDirect(exec->propertyNames().prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly);
// no. of arguments for constructor
putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontDelete | DontEnum);
}
ConstructType BooleanConstructor::getConstructData(ConstructData&)
......@@ -101,7 +101,7 @@ ConstructType BooleanConstructor::getConstructData(ConstructData&)
// ECMA 15.6.2
JSObject* BooleanConstructor::construct(ExecState* exec, const ArgList& args)
{
BooleanObject* obj(new BooleanObject(exec->lexicalGlobalObject()->booleanPrototype()));
BooleanObject* obj(new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanPrototype()));
obj->setInternalValue(jsBoolean(args[0]->toBoolean(exec)));
return obj;
}
......
......@@ -25,9 +25,6 @@
#define ExecState_h
#include "JSGlobalData.h"
#include "LabelStack.h"
#include "completion.h"
#include "list.h"
#include "ScopeChain.h"
namespace KJS {
......@@ -91,6 +88,8 @@ namespace KJS {
static const HashTable* regExpConstructorTable(ExecState* exec) { return exec->m_globalData->regExpConstructorTable; }
static const HashTable* stringTable(ExecState* exec) { return exec->m_globalData->stringTable; }
Heap* heap() const { return m_globalData->heap; }
private:
// Default constructor required for gcc 3.
ExecState() { }
......
......@@ -44,11 +44,11 @@ static JSValue* functionProtoFuncCall(ExecState*, JSObject*, const ArgList&);
FunctionPrototype::FunctionPrototype(ExecState* exec)
{
putDirect(exec->propertyNames().length, jsNumber(0), DontDelete | ReadOnly | DontEnum);
putDirect(exec->propertyNames().length, jsNumber(exec, 0), DontDelete | ReadOnly | DontEnum);
putDirectFunction(new PrototypeFunction(exec, this, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
putDirectFunction(new PrototypeFunction(exec, this, 2, exec->propertyNames().apply, functionProtoFuncApply), DontEnum);
putDirectFunction(new PrototypeFunction(exec, this, 1, exec->propertyNames().call, functionProtoFuncCall), DontEnum);
putDirectFunction(new (exec) PrototypeFunction(exec, this, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
putDirectFunction(new (exec) PrototypeFunction(exec, this, 2, exec->propertyNames().apply, functionProtoFuncApply), DontEnum);
putDirectFunction(new (exec) PrototypeFunction(exec, this, 1, exec->propertyNames().call, functionProtoFuncCall), DontEnum);
}
// ECMA 15.3.4
......@@ -70,10 +70,10 @@ JSValue* functionProtoFuncToString(ExecState* exec, JSObject* thisObj, const Arg
if (thisObj->inherits(&JSFunction::info)) {
JSFunction* fi = static_cast<JSFunction*>(thisObj);
return jsString("function " + fi->functionName().ustring() + "(" + fi->body->paramString() + ") " + fi->body->toSourceString());
return jsString(exec, "function " + fi->functionName().ustring() + "(" + fi->body->paramString() + ") " + fi->body->toSourceString());
}
return jsString("function " + static_cast<InternalFunction*>(thisObj)->functionName().ustring() + "() {\n [native code]\n}");
return jsString(exec, "function " + static_cast<InternalFunction*>(thisObj)->functionName().ustring() + "() {\n [native code]\n}");
}
JSValue* functionProtoFuncApply(ExecState* exec, JSObject* thisObj, const ArgList& args)
......@@ -133,7 +133,7 @@ FunctionConstructor::FunctionConstructor(ExecState* exec, FunctionPrototype* fun
putDirect(exec->propertyNames().prototype, functionPrototype, DontEnum | DontDelete | ReadOnly);
// Number of arguments for constructor
putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontDelete | DontEnum);
}
ConstructType FunctionConstructor::getConstructData(ConstructData&)
......@@ -174,7 +174,7 @@ JSObject* FunctionConstructor::construct(ExecState* exec, const ArgList& args, c
functionBody->setSource(SourceRange(source, 0, source->length()));
ScopeChain scopeChain(exec->lexicalGlobalObject(), exec->globalThisValue());
JSFunction* fimp = new JSFunction(exec, functionName, functionBody.get(), scopeChain.node());
JSFunction* fimp = new (exec) JSFunction(exec, functionName, functionBody.get(), scopeChain.node());
// parse parameter list. throw syntax error on illegal identifiers
int len = p.size();
......
......@@ -49,7 +49,7 @@ static void initializeThreadingOnce()
#if USE(MULTIPLE_THREADS)
s_dtoaP5Mutex = new Mutex;
#if !PLATFORM(DARWIN) // Darwin has pthread_main_np(), and doesn't need registerAsMainThread() called.
Collector::registerAsMainThread();
Heap::registerAsMainThread();
#endif
JSGlobalData::threadInstance();
UString::null();
......@@ -61,6 +61,10 @@ void initializeThreading()
{
#if PLATFORM(DARWIN)
pthread_once(&initializeThreadingKeyOnce, initializeThreadingOnce);
// FIXME: do we want heap introspector to work on other threads?
if (pthread_main_np())
JSGlobalData::threadInstance().heap->initializeHeapIntrospector();
#else
static bool initializedThreading = false;
if (!initializedThreading) {
......
......@@ -186,7 +186,7 @@ JSObject* JSActivation::createArgumentsObject(ExecState* exec)
int argc;
exec->machine()->getFunctionAndArguments(registerBase(), callFrame, function, argv, argc);
ArgList args(reinterpret_cast<JSValue***>(registerBase()), argv - *registerBase(), argc);
return new Arguments(exec, function, args, this);
return new (exec) Arguments(exec, function, args, this);
}
} // namespace KJS
......@@ -88,7 +88,7 @@ JSArray::JSArray(JSObject* prototype, unsigned initialLength)
m_vectorLength = initialCapacity;
m_storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity)));
Collector::reportExtraMemoryCost(initialCapacity * sizeof(JSValue*));
Heap::heap(this)->reportExtraMemoryCost(initialCapacity * sizeof(JSValue*));
checkConsistency();
}
......@@ -146,9 +146,9 @@ JSValue* JSArray::getItem(unsigned i) const
return value ? value : jsUndefined();
}
JSValue* JSArray::lengthGetter(ExecState*, const Identifier&, const PropertySlot& slot)
JSValue* JSArray::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
return jsNumber(static_cast<JSArray*>(slot.slotBase())->m_length);
return jsNumber(exec, static_cast<JSArray*>(slot.slotBase())->m_length);
}
ALWAYS_INLINE bool JSArray::inlineGetOwnPropertySlot(ExecState* exec, unsigned i, PropertySlot& slot)
......
......@@ -113,10 +113,10 @@ JSValue* JSFunction::callerGetter(ExecState* exec, const Identifier&, const Prop
return exec->machine()->retrieveCaller(exec, thisObj);
}
JSValue* JSFunction::lengthGetter(ExecState*, const Identifier&, const PropertySlot& slot)
JSValue* JSFunction::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
JSFunction* thisObj = static_cast<JSFunction*>(slot.slotBase());
return jsNumber(thisObj->body->parameters().size());
return jsNumber(exec, thisObj->body->parameters().size());
}
bool JSFunction::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
......@@ -195,7 +195,7 @@ JSObject* JSFunction::construct(ExecState* exec, const ArgList& args)
else
proto = exec->lexicalGlobalObject()->objectPrototype();
JSObject* thisObj = new JSObject(proto);
JSObject* thisObj = new (exec) JSObject(proto);
JSValue* exception = 0;
JSValue* result = machine().execute(body.get(), exec, this, thisObj, args, &exec->dynamicGlobalObject()->registerFileStack(), _scope.node(), &exception);
......@@ -284,7 +284,7 @@ Arguments::Arguments(ExecState* exec, JSFunction* func, const ArgList& args, JSA
, indexToNameMap(func, args)
{
putDirect(exec->propertyNames().callee, func, DontEnum);
putDirect(exec->propertyNames().length, args.size(), DontEnum);
putDirect(exec, exec->propertyNames().length, args.size(), DontEnum);
int i = 0;
ArgList::const_iterator end = args.end();
......@@ -355,7 +355,7 @@ static JSValue* encode(ExecState* exec, const ArgList& args, const char* do_not_
r += tmp;
}
}
return jsString(r);
return jsString(exec, r);
}
static JSValue* decode(ExecState* exec, const ArgList& args, const char* do_not_unescape, bool strict)
......@@ -420,7 +420,7 @@ static JSValue* decode(ExecState* exec, const ArgList& args, const char* do_not_
k++;
s.append(c);
}
return jsString(s);
return jsString(exec, s);
}
static bool isStrWhiteSpace(unsigned short c)
......@@ -592,12 +592,12 @@ JSValue* globalFuncEval(ExecState* exec, PrototypeReflexiveFunction* function, J
JSValue* globalFuncParseInt(ExecState* exec, JSObject*, const ArgList& args)
{
return jsNumber(parseInt(args[0]->toString(exec), args[1]->toInt32(exec)));
return jsNumber(exec, parseInt(args[0]->toString(exec), args[1]->toInt32(exec)));
}
JSValue* globalFuncParseFloat(ExecState* exec, JSObject*, const ArgList& args)
{
return jsNumber(parseFloat(args[0]->toString(exec)));
return jsNumber(exec, parseFloat(args[0]->toString(exec)));
}
JSValue* globalFuncIsNaN(ExecState* exec, JSObject*, const ArgList& args)
......@@ -672,7 +672,7 @@ JSValue* globalFuncEscape(ExecState* exec, JSObject*, const ArgList& args)
r += s;
}
return jsString(r);
return jsString(exec, r);
}
JSValue* globalFuncUnescape(ExecState* exec, JSObject*, const ArgList& args)
......@@ -697,7 +697,7 @@ JSValue* globalFuncUnescape(ExecState* exec, JSObject*, const ArgList& args)
s += UString(c, 1);
}
return jsString(s);
return jsString(exec, s);
}
#ifndef NDEBUG
......@@ -717,7 +717,7 @@ PrototypeFunction::PrototypeFunction(ExecState* exec, int len, const Identifier&
, m_function(function)
{
ASSERT_ARG(function, function);
putDirect(exec->propertyNames().length, jsNumber(len), DontDelete | ReadOnly | DontEnum);
putDirect(exec->propertyNames().length, jsNumber(exec, len), DontDelete | ReadOnly | DontEnum);