summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/runtime/JSGlobalObject.cpp')
-rw-r--r--Source/JavaScriptCore/runtime/JSGlobalObject.cpp174
1 files changed, 91 insertions, 83 deletions
diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
index ff7b1486f..97e9153cb 100644
--- a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
+++ b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
@@ -30,10 +30,6 @@
#include "config.h"
#include "JSGlobalObject.h"
-#include "JSCallbackConstructor.h"
-#include "JSCallbackFunction.h"
-#include "JSCallbackObject.h"
-
#include "Arguments.h"
#include "ArrayConstructor.h"
#include "ArrayPrototype.h"
@@ -42,18 +38,25 @@
#include "CodeBlock.h"
#include "DateConstructor.h"
#include "DatePrototype.h"
+#include "Debugger.h"
#include "Error.h"
#include "ErrorConstructor.h"
#include "ErrorPrototype.h"
#include "FunctionConstructor.h"
#include "FunctionPrototype.h"
#include "GetterSetter.h"
+#include "Interpreter.h"
+#include "JSActivation.h"
#include "JSBoundFunction.h"
+#include "JSCallbackConstructor.h"
+#include "JSCallbackFunction.h"
+#include "JSCallbackObject.h"
#include "JSFunction.h"
#include "JSGlobalObjectFunctions.h"
#include "JSLock.h"
+#include "JSNameScope.h"
#include "JSONObject.h"
-#include "Interpreter.h"
+#include "JSWithScope.h"
#include "Lookup.h"
#include "MathObject.h"
#include "NameConstructor.h"
@@ -70,16 +73,15 @@
#include "RegExpMatchesArray.h"
#include "RegExpObject.h"
#include "RegExpPrototype.h"
-#include "ScopeChainMark.h"
+#include "StrictEvalActivation.h"
#include "StringConstructor.h"
#include "StringPrototype.h"
-#include "Debugger.h"
#include "JSGlobalObject.lut.h"
namespace JSC {
-const ClassInfo JSGlobalObject::s_info = { "GlobalObject", &JSSegmentedVariableObject::s_info, 0, ExecState::globalObjectTable, CREATE_METHOD_TABLE(JSGlobalObject) };
+const ClassInfo JSGlobalObject::s_info = { "GlobalObject", &Base::s_info, 0, ExecState::globalObjectTable, CREATE_METHOD_TABLE(JSGlobalObject) };
const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptExperimentsEnabled };
@@ -106,15 +108,8 @@ static const int initialTickCountThreshold = 255;
// Preferred number of milliseconds between each timeout check
static const int preferredScriptCheckTimeInterval = 1000;
-template <typename T> static inline void visitIfNeeded(SlotVisitor& visitor, WriteBarrier<T>* v)
-{
- if (*v)
- visitor.append(v);
-}
-
JSGlobalObject::JSGlobalObject(JSGlobalData& globalData, Structure* structure, const GlobalObjectMethodTable* globalObjectMethodTable)
- : JSSegmentedVariableObject(globalData, structure, &m_symbolTable)
- , m_globalScopeChain()
+ : Base(globalData, structure, 0)
, m_masqueradesAsUndefinedWatchpoint(adoptRef(new WatchpointSet(InitializedWatching)))
, m_weakRandom(Options::forceWeakRandomSeed() ? Options::forcedWeakRandomSeed() : static_cast<unsigned>(randomNumber() * (std::numeric_limits<unsigned>::max() + 1.0)))
, m_evalEnabled(true)
@@ -136,13 +131,17 @@ void JSGlobalObject::destroy(JSCell* cell)
static_cast<JSGlobalObject*>(cell)->JSGlobalObject::~JSGlobalObject();
}
+void JSGlobalObject::setGlobalThis(JSGlobalData& globalData, JSObject* globalThis)
+{
+ m_globalThis.set(globalData, this, globalThis);
+}
+
void JSGlobalObject::init(JSObject* thisValue)
{
ASSERT(globalData().apiLock().currentThreadIsHoldingLock());
-
- m_globalScopeChain.set(globalData(), this, ScopeChainNode::create(0, this, &globalData(), this, thisValue));
- JSGlobalObject::globalExec()->init(0, 0, m_globalScopeChain.get(), CallFrame::noCaller(), 0, 0);
+ setGlobalThis(globalData(), thisValue);
+ JSGlobalObject::globalExec()->init(0, 0, this, CallFrame::noCaller(), 0, 0);
m_debugger = 0;
@@ -156,7 +155,7 @@ void JSGlobalObject::put(JSCell* cell, ExecState* exec, PropertyName propertyNam
if (symbolTablePut(thisObject, exec, propertyName, value, slot.isStrictMode()))
return;
- JSSegmentedVariableObject::put(thisObject, exec, propertyName, value, slot);
+ Base::put(thisObject, exec, propertyName, value, slot);
}
void JSGlobalObject::putDirectVirtual(JSObject* object, ExecState* exec, PropertyName propertyName, JSValue value, unsigned attributes)
@@ -169,7 +168,7 @@ void JSGlobalObject::putDirectVirtual(JSObject* object, ExecState* exec, Propert
JSValue valueBefore = thisObject->getDirect(exec->globalData(), propertyName);
PutPropertySlot slot;
- JSSegmentedVariableObject::put(thisObject, exec, propertyName, value, slot);
+ Base::put(thisObject, exec, propertyName, value, slot);
if (!valueBefore) {
JSValue valueAfter = thisObject->getDirect(exec->globalData(), propertyName);
if (valueAfter)
@@ -212,11 +211,16 @@ void JSGlobalObject::reset(JSValue prototype)
m_applyFunction.set(exec->globalData(), this, applyFunction);
m_objectPrototype.set(exec->globalData(), this, ObjectPrototype::create(exec, this, ObjectPrototype::createStructure(exec->globalData(), this, jsNull())));
GetterSetter* protoAccessor = GetterSetter::create(exec);
- protoAccessor->setGetter(exec->globalData(), JSFunction::create(exec, this, 0, "", globalFuncProtoGetter));
- protoAccessor->setSetter(exec->globalData(), JSFunction::create(exec, this, 0, "", globalFuncProtoSetter));
+ protoAccessor->setGetter(exec->globalData(), JSFunction::create(exec, this, 0, String(), globalFuncProtoGetter));
+ protoAccessor->setSetter(exec->globalData(), JSFunction::create(exec, this, 0, String(), globalFuncProtoSetter));
m_objectPrototype->putDirectAccessor(exec->globalData(), exec->propertyNames().underscoreProto, protoAccessor, Accessor | DontEnum);
m_functionPrototype->structure()->setPrototypeWithoutTransition(exec->globalData(), m_objectPrototype.get());
+ m_nameScopeStructure.set(exec->globalData(), this, JSNameScope::createStructure(exec->globalData(), this, jsNull()));
+ m_activationStructure.set(exec->globalData(), this, JSActivation::createStructure(exec->globalData(), this, jsNull()));
+ m_strictEvalActivationStructure.set(exec->globalData(), this, StrictEvalActivation::createStructure(exec->globalData(), this, jsNull()));
+ m_withScopeStructure.set(exec->globalData(), this, JSWithScope::createStructure(exec->globalData(), this, jsNull()));
+
m_emptyObjectStructure.set(exec->globalData(), this, m_objectPrototype->inheritorID(exec->globalData()));
m_nullPrototypeObjectStructure.set(exec->globalData(), this, createEmptyObjectStructure(exec->globalData(), this, jsNull()));
@@ -267,12 +271,12 @@ void JSGlobalObject::reset(JSValue prototype)
Structure* nativeErrorPrototypeStructure = NativeErrorPrototype::createStructure(exec->globalData(), this, m_errorPrototype.get());
Structure* nativeErrorStructure = NativeErrorConstructor::createStructure(exec->globalData(), this, m_functionPrototype.get());
- m_evalErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "EvalError"));
- m_rangeErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "RangeError"));
- m_referenceErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "ReferenceError"));
- m_syntaxErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "SyntaxError"));
- m_typeErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "TypeError"));
- m_URIErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "URIError"));
+ m_evalErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("EvalError")));
+ m_rangeErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("RangeError")));
+ m_referenceErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("ReferenceError")));
+ m_syntaxErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("SyntaxError")));
+ m_typeErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("TypeError")));
+ m_URIErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("URIError")));
m_objectPrototype->putDirectWithoutTransition(exec->globalData(), exec->propertyNames().constructor, objectConstructor, DontEnum);
m_functionPrototype->putDirectWithoutTransition(exec->globalData(), exec->propertyNames().constructor, functionConstructor, DontEnum);
@@ -300,7 +304,7 @@ void JSGlobalObject::reset(JSValue prototype)
putDirectWithoutTransition(exec->globalData(), Identifier(exec, "TypeError"), m_typeErrorConstructor.get(), DontEnum);
putDirectWithoutTransition(exec->globalData(), Identifier(exec, "URIError"), m_URIErrorConstructor.get(), DontEnum);
- m_evalFunction.set(exec->globalData(), this, JSFunction::create(exec, this, 1, exec->propertyNames().eval.ustring(), globalFuncEval));
+ m_evalFunction.set(exec->globalData(), this, JSFunction::create(exec, this, 1, exec->propertyNames().eval.string(), globalFuncEval));
putDirectWithoutTransition(exec->globalData(), exec->propertyNames().eval, m_evalFunction.get(), DontEnum);
putDirectWithoutTransition(exec->globalData(), Identifier(exec, "JSON"), JSONObject::create(exec, this, JSONObject::createStructure(exec->globalData(), this, m_objectPrototype.get())), DontEnum);
@@ -327,7 +331,7 @@ void JSGlobalObject::reset(JSValue prototype)
void JSGlobalObject::createThrowTypeError(ExecState* exec)
{
- JSFunction* thrower = JSFunction::create(exec, this, 0, "", globalFuncThrowTypeError);
+ JSFunction* thrower = JSFunction::create(exec, this, 0, String(), globalFuncThrowTypeError);
GetterSetter* getterSetter = GetterSetter::create(exec);
getterSetter->setGetter(exec->globalData(), thrower);
getterSetter->setSetter(exec->globalData(), thrower);
@@ -351,54 +355,58 @@ void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor)
ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
- JSSegmentedVariableObject::visitChildren(thisObject, visitor);
-
- visitIfNeeded(visitor, &thisObject->m_globalScopeChain);
- visitIfNeeded(visitor, &thisObject->m_methodCallDummy);
-
- visitIfNeeded(visitor, &thisObject->m_regExpConstructor);
- visitIfNeeded(visitor, &thisObject->m_errorConstructor);
- visitIfNeeded(visitor, &thisObject->m_evalErrorConstructor);
- visitIfNeeded(visitor, &thisObject->m_rangeErrorConstructor);
- visitIfNeeded(visitor, &thisObject->m_referenceErrorConstructor);
- visitIfNeeded(visitor, &thisObject->m_syntaxErrorConstructor);
- visitIfNeeded(visitor, &thisObject->m_typeErrorConstructor);
- visitIfNeeded(visitor, &thisObject->m_URIErrorConstructor);
-
- visitIfNeeded(visitor, &thisObject->m_evalFunction);
- visitIfNeeded(visitor, &thisObject->m_callFunction);
- visitIfNeeded(visitor, &thisObject->m_applyFunction);
- visitIfNeeded(visitor, &thisObject->m_throwTypeErrorGetterSetter);
-
- visitIfNeeded(visitor, &thisObject->m_objectPrototype);
- visitIfNeeded(visitor, &thisObject->m_functionPrototype);
- visitIfNeeded(visitor, &thisObject->m_arrayPrototype);
- visitIfNeeded(visitor, &thisObject->m_booleanPrototype);
- visitIfNeeded(visitor, &thisObject->m_stringPrototype);
- visitIfNeeded(visitor, &thisObject->m_numberPrototype);
- visitIfNeeded(visitor, &thisObject->m_datePrototype);
- visitIfNeeded(visitor, &thisObject->m_regExpPrototype);
- visitIfNeeded(visitor, &thisObject->m_errorPrototype);
-
- visitIfNeeded(visitor, &thisObject->m_argumentsStructure);
- visitIfNeeded(visitor, &thisObject->m_arrayStructure);
- visitIfNeeded(visitor, &thisObject->m_booleanObjectStructure);
- visitIfNeeded(visitor, &thisObject->m_callbackConstructorStructure);
- visitIfNeeded(visitor, &thisObject->m_callbackFunctionStructure);
- visitIfNeeded(visitor, &thisObject->m_callbackObjectStructure);
- visitIfNeeded(visitor, &thisObject->m_dateStructure);
- visitIfNeeded(visitor, &thisObject->m_emptyObjectStructure);
- visitIfNeeded(visitor, &thisObject->m_nullPrototypeObjectStructure);
- visitIfNeeded(visitor, &thisObject->m_errorStructure);
- visitIfNeeded(visitor, &thisObject->m_functionStructure);
- visitIfNeeded(visitor, &thisObject->m_boundFunctionStructure);
- visitIfNeeded(visitor, &thisObject->m_namedFunctionStructure);
- visitIfNeeded(visitor, &thisObject->m_numberObjectStructure);
- visitIfNeeded(visitor, &thisObject->m_privateNameStructure);
- visitIfNeeded(visitor, &thisObject->m_regExpMatchesArrayStructure);
- visitIfNeeded(visitor, &thisObject->m_regExpStructure);
- visitIfNeeded(visitor, &thisObject->m_stringObjectStructure);
- visitIfNeeded(visitor, &thisObject->m_internalFunctionStructure);
+ Base::visitChildren(thisObject, visitor);
+
+ visitor.append(&thisObject->m_globalThis);
+ visitor.append(&thisObject->m_methodCallDummy);
+
+ visitor.append(&thisObject->m_regExpConstructor);
+ visitor.append(&thisObject->m_errorConstructor);
+ visitor.append(&thisObject->m_evalErrorConstructor);
+ visitor.append(&thisObject->m_rangeErrorConstructor);
+ visitor.append(&thisObject->m_referenceErrorConstructor);
+ visitor.append(&thisObject->m_syntaxErrorConstructor);
+ visitor.append(&thisObject->m_typeErrorConstructor);
+ visitor.append(&thisObject->m_URIErrorConstructor);
+
+ visitor.append(&thisObject->m_evalFunction);
+ visitor.append(&thisObject->m_callFunction);
+ visitor.append(&thisObject->m_applyFunction);
+ visitor.append(&thisObject->m_throwTypeErrorGetterSetter);
+
+ visitor.append(&thisObject->m_objectPrototype);
+ visitor.append(&thisObject->m_functionPrototype);
+ visitor.append(&thisObject->m_arrayPrototype);
+ visitor.append(&thisObject->m_booleanPrototype);
+ visitor.append(&thisObject->m_stringPrototype);
+ visitor.append(&thisObject->m_numberPrototype);
+ visitor.append(&thisObject->m_datePrototype);
+ visitor.append(&thisObject->m_regExpPrototype);
+ visitor.append(&thisObject->m_errorPrototype);
+
+ visitor.append(&thisObject->m_withScopeStructure);
+ visitor.append(&thisObject->m_strictEvalActivationStructure);
+ visitor.append(&thisObject->m_activationStructure);
+ visitor.append(&thisObject->m_nameScopeStructure);
+ visitor.append(&thisObject->m_argumentsStructure);
+ visitor.append(&thisObject->m_arrayStructure);
+ visitor.append(&thisObject->m_booleanObjectStructure);
+ visitor.append(&thisObject->m_callbackConstructorStructure);
+ visitor.append(&thisObject->m_callbackFunctionStructure);
+ visitor.append(&thisObject->m_callbackObjectStructure);
+ visitor.append(&thisObject->m_dateStructure);
+ visitor.append(&thisObject->m_emptyObjectStructure);
+ visitor.append(&thisObject->m_nullPrototypeObjectStructure);
+ visitor.append(&thisObject->m_errorStructure);
+ visitor.append(&thisObject->m_functionStructure);
+ visitor.append(&thisObject->m_boundFunctionStructure);
+ visitor.append(&thisObject->m_namedFunctionStructure);
+ visitor.append(&thisObject->m_numberObjectStructure);
+ visitor.append(&thisObject->m_privateNameStructure);
+ visitor.append(&thisObject->m_regExpMatchesArrayStructure);
+ visitor.append(&thisObject->m_regExpStructure);
+ visitor.append(&thisObject->m_stringObjectStructure);
+ visitor.append(&thisObject->m_internalFunctionStructure);
}
ExecState* JSGlobalObject::globalExec()
@@ -414,9 +422,9 @@ void JSGlobalObject::addStaticGlobals(GlobalPropertyInfo* globals, int count)
GlobalPropertyInfo& global = globals[i];
ASSERT(global.attributes & DontDelete);
- int index = symbolTable().size();
+ int index = symbolTable()->size();
SymbolTableEntry newEntry(index, global.attributes);
- symbolTable().add(global.identifier.impl(), newEntry);
+ symbolTable()->add(global.identifier.impl(), newEntry);
registerAt(index).set(globalData(), this, global.value);
}
}
@@ -424,7 +432,7 @@ void JSGlobalObject::addStaticGlobals(GlobalPropertyInfo* globals, int count)
bool JSGlobalObject::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(cell);
- if (getStaticFunctionSlot<JSSegmentedVariableObject>(exec, ExecState::globalObjectTable(exec), thisObject, propertyName, slot))
+ if (getStaticFunctionSlot<Base>(exec, ExecState::globalObjectTable(exec), thisObject, propertyName, slot))
return true;
return symbolTableGet(thisObject, propertyName, slot);
}
@@ -432,7 +440,7 @@ bool JSGlobalObject::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyN
bool JSGlobalObject::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(object);
- if (getStaticFunctionDescriptor<JSSegmentedVariableObject>(exec, ExecState::globalObjectTable(exec), thisObject, propertyName, descriptor))
+ if (getStaticFunctionDescriptor<Base>(exec, ExecState::globalObjectTable(exec), thisObject, propertyName, descriptor))
return true;
return symbolTableGet(thisObject, propertyName, descriptor);
}