summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/runtime/JSGlobalObject.h
diff options
context:
space:
mode:
Diffstat (limited to 'JavaScriptCore/runtime/JSGlobalObject.h')
-rw-r--r--JavaScriptCore/runtime/JSGlobalObject.h61
1 files changed, 40 insertions, 21 deletions
diff --git a/JavaScriptCore/runtime/JSGlobalObject.h b/JavaScriptCore/runtime/JSGlobalObject.h
index bbb6d5e..714999f 100644
--- a/JavaScriptCore/runtime/JSGlobalObject.h
+++ b/JavaScriptCore/runtime/JSGlobalObject.h
@@ -25,11 +25,13 @@
#include "JSArray.h"
#include "JSGlobalData.h"
#include "JSVariableObject.h"
+#include "JSWeakObjectMapRefInternal.h"
#include "NativeFunctionWrapper.h"
#include "NumberPrototype.h"
#include "StringPrototype.h"
#include <wtf/HashSet.h>
#include <wtf/OwnPtr.h>
+#include <wtf/RandomNumber.h>
namespace JSC {
@@ -56,6 +58,7 @@ namespace JSC {
class JSGlobalObject : public JSVariableObject {
protected:
using JSVariableObject::JSVariableObjectData;
+ typedef HashSet<RefPtr<OpaqueJSWeakObjectMap> > WeakMapSet;
struct JSGlobalObjectData : public JSVariableObjectData {
// We use an explicit destructor function pointer instead of a
@@ -90,6 +93,7 @@ namespace JSC {
, datePrototype(0)
, regExpPrototype(0)
, methodCallDummy(0)
+ , weakRandom(static_cast<unsigned>(randomNumber() * (std::numeric_limits<unsigned>::max() + 1.0)))
{
}
@@ -105,8 +109,6 @@ namespace JSC {
ScopeChain globalScopeChain;
Register globalCallFrame[RegisterFile::CallFrameHeaderSize];
- int recursion;
-
RegExpConstructor* regExpConstructor;
ErrorConstructor* errorConstructor;
NativeErrorConstructor* evalErrorConstructor;
@@ -146,6 +148,7 @@ namespace JSC {
RefPtr<Structure> regExpMatchesArrayStructure;
RefPtr<Structure> regExpStructure;
RefPtr<Structure> stringObjectStructure;
+ RefPtr<Structure> internalFunctionStructure;
SymbolTable symbolTable;
unsigned profileGroup;
@@ -153,14 +156,26 @@ namespace JSC {
RefPtr<JSGlobalData> globalData;
HashSet<GlobalCodeBlock*> codeBlocks;
+ WeakMapSet weakMaps;
+ WeakRandom weakRandom;
};
public:
void* operator new(size_t, JSGlobalData*);
-
+
explicit JSGlobalObject()
: JSVariableObject(JSGlobalObject::createStructure(jsNull()), new JSGlobalObjectData(destroyJSGlobalObjectData))
{
+ COMPILE_ASSERT(JSGlobalObject::AnonymousSlotCount == 1, JSGlobalObject_has_only_a_single_slot);
+ putAnonymousValue(0, this);
+ init(this);
+ }
+
+ explicit JSGlobalObject(NonNullPassRefPtr<Structure> structure)
+ : JSVariableObject(structure, new JSGlobalObjectData(destroyJSGlobalObjectData))
+ {
+ COMPILE_ASSERT(JSGlobalObject::AnonymousSlotCount == 1, JSGlobalObject_has_only_a_single_slot);
+ putAnonymousValue(0, this);
init(this);
}
@@ -168,6 +183,8 @@ namespace JSC {
JSGlobalObject(NonNullPassRefPtr<Structure> structure, JSGlobalObjectData* data, JSObject* thisValue)
: JSVariableObject(structure, data)
{
+ COMPILE_ASSERT(JSGlobalObject::AnonymousSlotCount == 1, JSGlobalObject_has_only_a_single_slot);
+ putAnonymousValue(0, this);
init(thisValue);
}
@@ -227,6 +244,7 @@ namespace JSC {
Structure* functionStructure() const { return d()->functionStructure.get(); }
Structure* numberObjectStructure() const { return d()->numberObjectStructure.get(); }
Structure* prototypeFunctionStructure() const { return d()->prototypeFunctionStructure.get(); }
+ Structure* internalFunctionStructure() const { return d()->internalFunctionStructure.get(); }
Structure* regExpMatchesArrayStructure() const { return d()->regExpMatchesArrayStructure.get(); }
Structure* regExpStructure() const { return d()->regExpStructure.get(); }
Structure* stringObjectStructure() const { return d()->stringObjectStructure.get(); }
@@ -236,13 +254,10 @@ namespace JSC {
Debugger* debugger() const { return d()->debugger; }
void setDebugger(Debugger* debugger) { d()->debugger = debugger; }
-
+
virtual bool supportsProfiling() const { return false; }
-
- int recursion() { return d()->recursion; }
- void incRecursion() { ++d()->recursion; }
- void decRecursion() { --d()->recursion; }
-
+ virtual bool supportsRichSourceInfo() const { return true; }
+
ScopeChain& globalScopeChain() { return d()->globalScopeChain; }
virtual bool isGlobalObject() const { return true; }
@@ -253,7 +268,7 @@ namespace JSC {
virtual bool allowsAccessFrom(const JSGlobalObject*) const { return true; }
- virtual bool isDynamicScope() const;
+ virtual bool isDynamicScope(bool& requiresDynamicChecks) const;
HashSet<GlobalCodeBlock*>& codeBlocks() { return d()->codeBlocks; }
@@ -262,7 +277,7 @@ namespace JSC {
void resetPrototype(JSValue prototype);
- JSGlobalData* globalData() { return d()->globalData.get(); }
+ JSGlobalData& globalData() const { return *d()->globalData.get(); }
JSGlobalObjectData* d() const { return static_cast<JSGlobalObjectData*>(JSVariableObject::d); }
static PassRefPtr<Structure> createStructure(JSValue prototype)
@@ -270,8 +285,20 @@ namespace JSC {
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
+ void registerWeakMap(OpaqueJSWeakObjectMap* map)
+ {
+ d()->weakMaps.add(map);
+ }
+
+ void deregisterWeakMap(OpaqueJSWeakObjectMap* map)
+ {
+ d()->weakMaps.remove(map);
+ }
+
+ double weakRandomNumber() { return d()->weakRandom.get(); }
protected:
+ static const unsigned AnonymousSlotCount = JSVariableObject::AnonymousSlotCount + 1;
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesMarkChildren | OverridesGetPropertyNames | JSVariableObject::StructureFlags;
struct GlobalPropertyInfo {
@@ -327,7 +354,7 @@ namespace JSC {
GlobalPropertyInfo& global = globals[i];
ASSERT(global.attributes & DontDelete);
SymbolTableEntry newEntry(index, global.attributes);
- symbolTable().add(global.identifier.ustring().rep(), newEntry);
+ symbolTable().add(global.identifier.impl(), newEntry);
registerAt(index) = global.value;
}
}
@@ -360,16 +387,8 @@ namespace JSC {
if (typeInfo().type() == ObjectType)
return m_prototype;
-#if USE(JSVALUE32)
- if (typeInfo().type() == StringType)
- return exec->lexicalGlobalObject()->stringPrototype();
-
- ASSERT(typeInfo().type() == NumberType);
- return exec->lexicalGlobalObject()->numberPrototype();
-#else
ASSERT(typeInfo().type() == StringType);
return exec->lexicalGlobalObject()->stringPrototype();
-#endif
}
inline StructureChain* Structure::prototypeChain(ExecState* exec) const
@@ -431,7 +450,7 @@ namespace JSC {
inline JSArray* constructEmptyArray(ExecState* exec, unsigned initialLength)
{
- return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), initialLength);
+ return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), initialLength, CreateInitialized);
}
inline JSArray* constructArray(ExecState* exec, JSValue singleItemValue)