Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (198227 => 198228)
--- trunk/Source/_javascript_Core/ChangeLog 2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-03-15 20:41:00 UTC (rev 198228)
@@ -1,3 +1,55 @@
+2016-03-15 Saam Barati <[email protected]>
+
+ We should have different JSTypes for JSGlobalLexicalEnvironment and JSLexicalEnvironment and JSModuleEnvironment
+ https://bugs.webkit.org/show_bug.cgi?id=152406
+
+ Reviewed by Mark Lam.
+
+ This makes testing for a JSGlobalLexicalEnvironment faster
+ because we can just check the Cell's type instead of using
+ jsDynamicCast. I also changed code that does jsDynamicCast<JSGlobalObject*>
+ instead of isGlobalObject().
+
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::execute):
+ * jit/JITOperations.cpp:
+ * llint/LLIntSlowPaths.cpp:
+ (JSC::LLInt::LLINT_SLOW_PATH_DECL):
+ * runtime/CommonSlowPaths.cpp:
+ (JSC::SLOW_PATH_DECL):
+ * runtime/CommonSlowPaths.h:
+ (JSC::CommonSlowPaths::tryCachePutToScopeGlobal):
+ (JSC::CommonSlowPaths::tryCacheGetFromScopeGlobal):
+ * runtime/JSGlobalLexicalEnvironment.h:
+ (JSC::JSGlobalLexicalEnvironment::createStructure):
+ * runtime/JSLexicalEnvironment.h:
+ (JSC::JSLexicalEnvironment::createStructure):
+ (JSC::JSLexicalEnvironment::JSLexicalEnvironment):
+ * runtime/JSModuleEnvironment.h:
+ (JSC::JSModuleEnvironment::createStructure):
+ (JSC::JSModuleEnvironment::offsetOfModuleRecord):
+ * runtime/JSObject.h:
+ (JSC::JSObject::isGlobalObject):
+ (JSC::JSObject::isJSLexicalEnvironment):
+ (JSC::JSObject::isGlobalLexicalEnvironment):
+ (JSC::JSObject::isErrorInstance):
+ * runtime/JSScope.cpp:
+ (JSC::abstractAccess):
+ (JSC::isUnscopable):
+ (JSC::JSScope::resolve):
+ (JSC::JSScope::collectVariablesUnderTDZ):
+ (JSC::JSScope::isVarScope):
+ (JSC::JSScope::isLexicalScope):
+ (JSC::JSScope::isModuleScope):
+ (JSC::JSScope::isCatchScope):
+ (JSC::JSScope::isFunctionNameScopeObject):
+ (JSC::JSScope::isNestedLexicalScope):
+ (JSC::JSScope::constantScopeForCodeBlock):
+ (JSC::isScopeType): Deleted.
+ (JSC::JSScope::isGlobalLexicalEnvironment): Deleted.
+ * runtime/JSScope.h:
+ * runtime/JSType.h:
+
2016-03-15 Filip Pizlo <[email protected]>
Remove the Baker barrier from JSC
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (198227 => 198228)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2016-03-15 20:41:00 UTC (rev 198228)
@@ -1202,7 +1202,8 @@
variableObject = node;
break;
}
- if (JSLexicalEnvironment* lexicalEnvironment = jsDynamicCast<JSLexicalEnvironment*>(node)) {
+ if (node->isJSLexicalEnvironment()) {
+ JSLexicalEnvironment* lexicalEnvironment = jsCast<JSLexicalEnvironment*>(node);
if (lexicalEnvironment->symbolTable()->scopeType() == SymbolTable::ScopeType::VarScope) {
variableObject = node;
break;
Modified: trunk/Source/_javascript_Core/jit/JITOperations.cpp (198227 => 198228)
--- trunk/Source/_javascript_Core/jit/JITOperations.cpp 2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/_javascript_Core/jit/JITOperations.cpp 2016-03-15 20:41:00 UTC (rev 198228)
@@ -1891,7 +1891,7 @@
}
JSValue result = JSValue();
- if (jsDynamicCast<JSGlobalLexicalEnvironment*>(scope)) {
+ if (scope->isGlobalLexicalEnvironment()) {
// When we can't statically prove we need a TDZ check, we must perform the check on the slow path.
result = slot.getValue(exec, ident);
if (result == jsTDZValue()) {
@@ -1932,7 +1932,7 @@
bool hasProperty = scope->hasProperty(exec, ident);
if (hasProperty
- && jsDynamicCast<JSGlobalLexicalEnvironment*>(scope)
+ && scope->isGlobalLexicalEnvironment()
&& getPutInfo.initializationMode() != Initialization) {
// When we can't statically prove we need a TDZ check, we must perform the check on the slow path.
PropertySlot slot(scope, PropertySlot::InternalMethodType::Get);
Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp (198227 => 198228)
--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp 2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp 2016-03-15 20:41:00 UTC (rev 198228)
@@ -1422,7 +1422,7 @@
}
JSValue result = JSValue();
- if (jsDynamicCast<JSGlobalLexicalEnvironment*>(scope)) {
+ if (scope->isGlobalLexicalEnvironment()) {
// When we can't statically prove we need a TDZ check, we must perform the check on the slow path.
result = slot.getValue(exec, ident);
if (result == jsTDZValue())
@@ -1459,7 +1459,7 @@
bool hasProperty = scope->hasProperty(exec, ident);
if (hasProperty
- && jsDynamicCast<JSGlobalLexicalEnvironment*>(scope)
+ && scope->isGlobalLexicalEnvironment()
&& getPutInfo.initializationMode() != Initialization) {
// When we can't statically prove we need a TDZ check, we must perform the check on the slow path.
PropertySlot slot(scope, PropertySlot::InternalMethodType::Get);
Modified: trunk/Source/_javascript_Core/runtime/CommonSlowPaths.cpp (198227 => 198228)
--- trunk/Source/_javascript_Core/runtime/CommonSlowPaths.cpp 2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/_javascript_Core/runtime/CommonSlowPaths.cpp 2016-03-15 20:41:00 UTC (rev 198228)
@@ -769,7 +769,7 @@
BEGIN();
const Identifier& ident = exec->codeBlock()->identifier(pc[3].u.operand);
JSScope* scope = exec->uncheckedR(pc[2].u.operand).Register::scope();
- JSValue resolvedScope = JSScope::resolve(exec, scope, ident);
+ JSObject* resolvedScope = JSScope::resolve(exec, scope, ident);
ResolveType resolveType = static_cast<ResolveType>(pc[4].u.operand);
@@ -777,13 +777,8 @@
ASSERT(resolveType != ModuleVar);
if (resolveType == UnresolvedProperty || resolveType == UnresolvedPropertyWithVarInjectionChecks) {
- if (JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsDynamicCast<JSGlobalLexicalEnvironment*>(resolvedScope)) {
- if (resolveType == UnresolvedProperty)
- pc[4].u.operand = GlobalLexicalVar;
- else
- pc[4].u.operand = GlobalLexicalVarWithVarInjectionChecks;
- pc[6].u.pointer = globalLexicalEnvironment;
- } else if (JSGlobalObject* globalObject = jsDynamicCast<JSGlobalObject*>(resolvedScope)) {
+ if (resolvedScope->isGlobalObject()) {
+ JSGlobalObject* globalObject = jsCast<JSGlobalObject*>(resolvedScope);
if (globalObject->hasProperty(exec, ident)) {
if (resolveType == UnresolvedProperty)
pc[4].u.operand = GlobalProperty;
@@ -792,6 +787,13 @@
pc[6].u.pointer = globalObject;
}
+ } else if (resolvedScope->isGlobalLexicalEnvironment()) {
+ JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsCast<JSGlobalLexicalEnvironment*>(resolvedScope);
+ if (resolveType == UnresolvedProperty)
+ pc[4].u.operand = GlobalLexicalVar;
+ else
+ pc[4].u.operand = GlobalLexicalVarWithVarInjectionChecks;
+ pc[6].u.pointer = globalLexicalEnvironment;
}
}
Modified: trunk/Source/_javascript_Core/runtime/CommonSlowPaths.h (198227 => 198228)
--- trunk/Source/_javascript_Core/runtime/CommonSlowPaths.h 2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/_javascript_Core/runtime/CommonSlowPaths.h 2016-03-15 20:41:00 UTC (rev 198228)
@@ -100,18 +100,19 @@
return;
if (resolveType == UnresolvedProperty || resolveType == UnresolvedPropertyWithVarInjectionChecks) {
- if (JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsDynamicCast<JSGlobalLexicalEnvironment*>(scope)) {
+ if (scope->isGlobalObject()) {
+ ResolveType newResolveType = resolveType == UnresolvedProperty ? GlobalProperty : GlobalPropertyWithVarInjectionChecks;
+ resolveType = newResolveType;
+ getPutInfo = GetPutInfo(getPutInfo.resolveMode(), newResolveType, getPutInfo.initializationMode());
+ pc[4].u.operand = getPutInfo.operand();
+ } else if (scope->isGlobalLexicalEnvironment()) {
+ JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsCast<JSGlobalLexicalEnvironment*>(scope);
ResolveType newResolveType = resolveType == UnresolvedProperty ? GlobalLexicalVar : GlobalLexicalVarWithVarInjectionChecks;
pc[4].u.operand = GetPutInfo(getPutInfo.resolveMode(), newResolveType, getPutInfo.initializationMode()).operand();
SymbolTableEntry entry = globalLexicalEnvironment->symbolTable()->get(ident.impl());
ASSERT(!entry.isNull());
pc[5].u.watchpointSet = entry.watchpointSet();
pc[6].u.pointer = static_cast<void*>(globalLexicalEnvironment->variableAt(entry.scopeOffset()).slot());
- } else if (jsDynamicCast<JSGlobalObject*>(scope)) {
- ResolveType newResolveType = resolveType == UnresolvedProperty ? GlobalProperty : GlobalPropertyWithVarInjectionChecks;
- resolveType = newResolveType;
- getPutInfo = GetPutInfo(getPutInfo.resolveMode(), newResolveType, getPutInfo.initializationMode());
- pc[4].u.operand = getPutInfo.operand();
}
}
@@ -142,17 +143,18 @@
ResolveType resolveType = getPutInfo.resolveType();
if (resolveType == UnresolvedProperty || resolveType == UnresolvedPropertyWithVarInjectionChecks) {
- if (JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsDynamicCast<JSGlobalLexicalEnvironment*>(scope)) {
+ if (scope->isGlobalObject()) {
+ ResolveType newResolveType = resolveType == UnresolvedProperty ? GlobalProperty : GlobalPropertyWithVarInjectionChecks;
+ resolveType = newResolveType; // Allow below caching mechanism to kick in.
+ pc[4].u.operand = GetPutInfo(getPutInfo.resolveMode(), newResolveType, getPutInfo.initializationMode()).operand();
+ } else if (scope->isGlobalLexicalEnvironment()) {
+ JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsCast<JSGlobalLexicalEnvironment*>(scope);
ResolveType newResolveType = resolveType == UnresolvedProperty ? GlobalLexicalVar : GlobalLexicalVarWithVarInjectionChecks;
pc[4].u.operand = GetPutInfo(getPutInfo.resolveMode(), newResolveType, getPutInfo.initializationMode()).operand();
SymbolTableEntry entry = globalLexicalEnvironment->symbolTable()->get(ident.impl());
ASSERT(!entry.isNull());
pc[5].u.watchpointSet = entry.watchpointSet();
pc[6].u.pointer = static_cast<void*>(globalLexicalEnvironment->variableAt(entry.scopeOffset()).slot());
- } else if (jsDynamicCast<JSGlobalObject*>(scope)) {
- ResolveType newResolveType = resolveType == UnresolvedProperty ? GlobalProperty : GlobalPropertyWithVarInjectionChecks;
- resolveType = newResolveType; // Allow below caching mechanism to kick in.
- pc[4].u.operand = GetPutInfo(getPutInfo.resolveMode(), newResolveType, getPutInfo.initializationMode()).operand();
}
}
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalLexicalEnvironment.h (198227 => 198228)
--- trunk/Source/_javascript_Core/runtime/JSGlobalLexicalEnvironment.h 2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalLexicalEnvironment.h 2016-03-15 20:41:00 UTC (rev 198228)
@@ -55,7 +55,7 @@
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject)
{
- return Structure::create(vm, globalObject, jsNull(), TypeInfo(ClosureObjectType, StructureFlags), info());
+ return Structure::create(vm, globalObject, jsNull(), TypeInfo(GlobalLexicalEnvironmentType, StructureFlags), info());
}
protected:
Modified: trunk/Source/_javascript_Core/runtime/JSLexicalEnvironment.h (198227 => 198228)
--- trunk/Source/_javascript_Core/runtime/JSLexicalEnvironment.h 2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/_javascript_Core/runtime/JSLexicalEnvironment.h 2016-03-15 20:41:00 UTC (rev 198228)
@@ -75,7 +75,7 @@
DECLARE_INFO;
- static Structure* createStructure(VM& vm, JSGlobalObject* globalObject) { return Structure::create(vm, globalObject, jsNull(), TypeInfo(ClosureObjectType, StructureFlags), info()); }
+ static Structure* createStructure(VM& vm, JSGlobalObject* globalObject) { return Structure::create(vm, globalObject, jsNull(), TypeInfo(LexicalEnvironmentType, StructureFlags), info()); }
};
inline JSLexicalEnvironment::JSLexicalEnvironment(VM& vm, Structure* structure, JSScope* currentScope, SymbolTable* symbolTable)
Modified: trunk/Source/_javascript_Core/runtime/JSModuleEnvironment.h (198227 => 198228)
--- trunk/Source/_javascript_Core/runtime/JSModuleEnvironment.h 2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/_javascript_Core/runtime/JSModuleEnvironment.h 2016-03-15 20:41:00 UTC (rev 198228)
@@ -55,7 +55,7 @@
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject)
{
- return Structure::create(vm, globalObject, jsNull(), TypeInfo(ObjectType, StructureFlags), info());
+ return Structure::create(vm, globalObject, jsNull(), TypeInfo(ModuleEnvironmentType, StructureFlags), info());
}
static size_t offsetOfModuleRecord(SymbolTable* symbolTable)
Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (198227 => 198228)
--- trunk/Source/_javascript_Core/runtime/JSObject.h 2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h 2016-03-15 20:41:00 UTC (rev 198228)
@@ -641,6 +641,8 @@
JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, const PropertyDescriptor&, bool shouldThrow);
bool isGlobalObject() const;
+ bool isJSLexicalEnvironment() const;
+ bool isGlobalLexicalEnvironment() const;
bool isErrorInstance() const;
bool isWithScope() const;
@@ -1076,6 +1078,16 @@
return type() == GlobalObjectType;
}
+inline bool JSObject::isJSLexicalEnvironment() const
+{
+ return type() == LexicalEnvironmentType || type() == ModuleEnvironmentType;
+}
+
+inline bool JSObject::isGlobalLexicalEnvironment() const
+{
+ return type() == GlobalLexicalEnvironmentType;
+}
+
inline bool JSObject::isErrorInstance() const
{
return type() == ErrorInstanceType;
Modified: trunk/Source/_javascript_Core/runtime/JSScope.cpp (198227 => 198228)
--- trunk/Source/_javascript_Core/runtime/JSScope.cpp 2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/_javascript_Core/runtime/JSScope.cpp 2016-03-15 20:41:00 UTC (rev 198228)
@@ -48,7 +48,8 @@
// Returns true if we found enough information to terminate optimization.
static inline bool abstractAccess(ExecState* exec, JSScope* scope, const Identifier& ident, GetOrPut getOrPut, size_t depth, bool& needsVarInjectionChecks, ResolveOp& op, InitializationMode initializationMode)
{
- if (JSLexicalEnvironment* lexicalEnvironment = jsDynamicCast<JSLexicalEnvironment*>(scope)) {
+ if (scope->isJSLexicalEnvironment()) {
+ JSLexicalEnvironment* lexicalEnvironment = jsCast<JSLexicalEnvironment*>(scope);
if (ident == exec->propertyNames().arguments) {
// We know the property will be at this lexical environment scope, but we don't know how to cache it.
op = ResolveOp(Dynamic, 0, 0, 0, 0, 0);
@@ -67,7 +68,8 @@
return true;
}
- if (JSModuleEnvironment* moduleEnvironment = jsDynamicCast<JSModuleEnvironment*>(scope)) {
+ if (scope->type() == ModuleEnvironmentType) {
+ JSModuleEnvironment* moduleEnvironment = jsCast<JSModuleEnvironment*>(scope);
JSModuleRecord* moduleRecord = moduleEnvironment->moduleRecord();
JSModuleRecord::Resolution resolution = moduleRecord->resolveImport(exec, ident);
if (resolution.type == JSModuleRecord::Resolution::Type::Resolved) {
@@ -85,7 +87,8 @@
return false;
}
- if (JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsDynamicCast<JSGlobalLexicalEnvironment*>(scope)) {
+ if (scope->isGlobalLexicalEnvironment()) {
+ JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsCast<JSGlobalLexicalEnvironment*>(scope);
SymbolTableEntry entry = globalLexicalEnvironment->symbolTable()->get(ident.impl());
if (!entry.isNull()) {
if (getOrPut == Put && entry.isReadOnly() && initializationMode != Initialization) {
@@ -112,7 +115,8 @@
return false;
}
- if (JSGlobalObject* globalObject = jsDynamicCast<JSGlobalObject*>(scope)) {
+ if (scope->isGlobalObject()) {
+ JSGlobalObject* globalObject = jsCast<JSGlobalObject*>(scope);
SymbolTableEntry entry = globalObject->symbolTable()->get(ident.impl());
if (!entry.isNull()) {
if (getOrPut == Put && entry.isReadOnly()) {
@@ -190,7 +194,7 @@
return blocked.toBoolean(exec);
}
-JSValue JSScope::resolve(ExecState* exec, JSScope* scope, const Identifier& ident)
+JSObject* JSScope::resolve(ExecState* exec, JSScope* scope, const Identifier& ident)
{
ScopeChainIterator end = scope->end();
ScopeChainIterator it = scope->begin();
@@ -246,51 +250,44 @@
}
}
-template <typename EnvironmentType, SymbolTable::ScopeType scopeType>
-inline static bool isScopeType(JSScope* scope)
+bool JSScope::isVarScope()
{
- EnvironmentType* environment = jsDynamicCast<EnvironmentType*>(scope);
- if (!environment)
+ if (type() != LexicalEnvironmentType)
return false;
-
- return environment->symbolTable()->scopeType() == scopeType;
+ return jsCast<JSLexicalEnvironment*>(this)->symbolTable()->scopeType() == SymbolTable::ScopeType::VarScope;
}
-bool JSScope::isVarScope()
-{
- return isScopeType<JSLexicalEnvironment, SymbolTable::ScopeType::VarScope>(this);
-}
-
bool JSScope::isLexicalScope()
{
- return isScopeType<JSLexicalEnvironment, SymbolTable::ScopeType::LexicalScope>(this);
+ if (!isJSLexicalEnvironment())
+ return false;
+ return jsCast<JSLexicalEnvironment*>(this)->symbolTable()->scopeType() == SymbolTable::ScopeType::LexicalScope;
}
bool JSScope::isModuleScope()
{
- return isScopeType<JSModuleEnvironment, SymbolTable::ScopeType::LexicalScope>(this);
+ return type() == ModuleEnvironmentType;
}
bool JSScope::isCatchScope()
{
- return isScopeType<JSLexicalEnvironment, SymbolTable::ScopeType::CatchScope>(this);
+ if (type() != LexicalEnvironmentType)
+ return false;
+ return jsCast<JSLexicalEnvironment*>(this)->symbolTable()->scopeType() == SymbolTable::ScopeType::CatchScope;
}
bool JSScope::isFunctionNameScopeObject()
{
- return isScopeType<JSLexicalEnvironment, SymbolTable::ScopeType::FunctionNameScope>(this);
+ if (type() != LexicalEnvironmentType)
+ return false;
+ return jsCast<JSLexicalEnvironment*>(this)->symbolTable()->scopeType() == SymbolTable::ScopeType::FunctionNameScope;
}
-bool JSScope::isGlobalLexicalEnvironment()
-{
- return isScopeType<JSGlobalLexicalEnvironment, SymbolTable::ScopeType::GlobalLexicalScope>(this);
-}
-
bool JSScope::isNestedLexicalScope()
{
- if (JSLexicalEnvironment* environment = jsDynamicCast<JSLexicalEnvironment*>(this))
- return environment->symbolTable()->isNestedLexicalScope();
- return false;
+ if (!isJSLexicalEnvironment())
+ return false;
+ return jsCast<JSLexicalEnvironment*>(this)->symbolTable()->isNestedLexicalScope();
}
JSScope* JSScope::constantScopeForCodeBlock(ResolveType type, CodeBlock* codeBlock)
Modified: trunk/Source/_javascript_Core/runtime/JSScope.h (198227 => 198228)
--- trunk/Source/_javascript_Core/runtime/JSScope.h 2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/_javascript_Core/runtime/JSScope.h 2016-03-15 20:41:00 UTC (rev 198228)
@@ -45,7 +45,7 @@
static JSObject* objectAtScope(JSScope*);
- static JSValue resolve(ExecState*, JSScope*, const Identifier&);
+ static JSObject* resolve(ExecState*, JSScope*, const Identifier&);
static ResolveOp abstractResolve(ExecState*, size_t depthOffset, JSScope*, const Identifier&, GetOrPut, ResolveType, InitializationMode);
static bool hasConstantScope(ResolveType);
@@ -58,7 +58,6 @@
bool isVarScope();
bool isLexicalScope();
bool isModuleScope();
- bool isGlobalLexicalEnvironment();
bool isCatchScope();
bool isFunctionNameScopeObject();
Modified: trunk/Source/_javascript_Core/runtime/JSType.h (198227 => 198228)
--- trunk/Source/_javascript_Core/runtime/JSType.h 2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/_javascript_Core/runtime/JSType.h 2016-03-15 20:41:00 UTC (rev 198228)
@@ -76,7 +76,9 @@
DataViewType,
GlobalObjectType,
- ClosureObjectType,
+ LexicalEnvironmentType,
+ GlobalLexicalEnvironmentType,
+ ModuleEnvironmentType,
RegExpObjectType,
ProxyObjectType,